home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / GameCreators / TADS / adv.t < prev    next >
Encoding:
Text File  |  1996-11-22  |  115.1 KB  |  4,286 lines

  1. /* Copyright (c) 1988, 1994 by Michael J. Roberts.  All Rights Reserved. */
  2. /*
  3.    adv.t  - standard adventure definitions for TADS games
  4.    Version 2.2
  5.  
  6.    This file is part of TADS:  The Text Adventure Development System.
  7.    Please see the file LICENSE.DOC (which should be part of the TADS
  8.    distribution) for information on using this file.
  9.  
  10.    This file defines the basic classes and functions used by most TADS
  11.    adventure games.  It is generally #include'd at the start of each game
  12.    source file.
  13. */
  14.  
  15. /* parse adv.t using normal TADS operators */
  16. #pragma C-
  17.  
  18. /*
  19.  *   Define compound prepositions.  Since prepositions that appear in
  20.  *   parsed sentences must be single words, we must define any logical
  21.  *   prepositions that consist of two or more words here.  Note that
  22.  *   only two words can be pasted together at once; to paste more, use
  23.  *   a second step.  For example,  'out from under' must be defined in
  24.  *   two steps:
  25.  *
  26.  *     compoundWord 'out' 'from' 'outfrom';
  27.  *     compoundWord 'outfrom' 'under' 'outfromunder';
  28.  *
  29.  *   Listed below are the compound prepositions that were built in to
  30.  *   version 1.0 of the TADS run-time.
  31.  */
  32. compoundWord 'on' 'to' 'onto';           /* on to --> onto */
  33. compoundWord 'in' 'to' 'into';           /* in to --> into */
  34. compoundWord 'in' 'between' 'inbetween'; /* and so forth */
  35. compoundWord 'down' 'in' 'downin';
  36. compoundWord 'down' 'on' 'downon';
  37. compoundWord 'up' 'on' 'upon';
  38. compoundWord 'out' 'of' 'outof';
  39. compoundWord 'off' 'of' 'offof';
  40. ;
  41.  
  42. /*
  43.  *   Format strings:  these associate keywords with properties.  When
  44.  *   a keyword appears in output between percent signs (%), the matching
  45.  *   property of the current command's actor is evaluated and substituted
  46.  *   for the keyword (and the percent signs).  For example, if you have:
  47.  *
  48.  *      formatstring 'you' fmtYou;
  49.  *
  50.  *   and the command being processed is:
  51.  *
  52.  *      fred, pick up the paper
  53.  *
  54.  *   and the "fred" actor has fmtYou = "he", and this string is output:
  55.  *
  56.  *      "%You% can't see that here."
  57.  *
  58.  *   Then the actual output is:  "He can't see that here."
  59.  *
  60.  *   The format strings are chosen to look like normal output (minus the
  61.  *   percent signs, of course) when the actor is Me.
  62.  */
  63. formatstring 'you' fmtYou;
  64. formatstring 'your' fmtYour;
  65. formatstring 'you\'re' fmtYoure;
  66. formatstring 'youm' fmtYoum;
  67. formatstring 'you\'ve' fmtYouve;
  68. formatstring 's' fmtS;
  69. formatstring 'es' fmtEs;
  70. formatstring 'have' fmtHave;
  71. formatstring 'do' fmtDo;
  72. formatstring 'are' fmtAre;
  73. formatstring 'me' fmtMe;
  74. ;
  75.  
  76. /*
  77.  *   Special Word List: This list defines the special words that the
  78.  *   parser needs for input commands.  If the list is not provided, the
  79.  *   parser uses the old defaults.  The list below is the same as the old
  80.  *   defaults.  Note - the words in this list must appear in the order
  81.  *   shown below.
  82.  */
  83. specialWords
  84.     'of',                        /* used in phrases such as "piece of paper" */
  85.     'and',             /* conjunction for noun lists or to separate commands */
  86.     'then',                              /* conjunction to separate commands */
  87.     'all' = 'everything',               /* refers to every accessible object */
  88.     'both',      /* used with plurals, or to answer disambiguation questions */
  89.     'but' = 'except',                      /* used to exclude items from ALL */
  90.     'one',                       /* used to answer questions:  "the red one" */
  91.     'ones',                        /* likewise for plurals:  "the blue ones" */
  92.     'it' = 'there',              /* refers to last single direct object used */
  93.     'them',                             /* refers to last direct object list */
  94.     'him',                       /* refers to last masculine actor mentioned */
  95.     'her',                        /* refers to last feminine actor mentioned */
  96.     'any' = 'either'         /* pick object arbitrarily from ambiguous list */
  97. ;
  98.  
  99. /*
  100.  *   Forward-declare functions.  This is not required in most cases,
  101.  *   but it doesn't hurt.  Providing these forward declarations ensures
  102.  *   that the compiler knows that we want these symbols to refer to
  103.  *   functions rather than objects.
  104.  */
  105. checkDoor: function;
  106. checkReach: function;
  107. itemcnt: function;
  108. isIndistinguishable: function;
  109. sayPrefixCount: function;
  110. listcont: function;
  111. listcontcont: function;
  112. turncount: function;
  113. addweight: function;
  114. addbulk: function;
  115. incscore: function;
  116. darkTravel: function;
  117. scoreRank: function;
  118. terminate: function;
  119. goToSleep: function;
  120. initSearch: function;
  121. reachableList: function;
  122. initRestart: function;
  123. ;
  124.  
  125. /*
  126.  *   initRestart - flag when a restart has occurred by setting a flag
  127.  *   in global.
  128.  */
  129. initRestart: function(parm)
  130. {
  131.     global.restarting := true;
  132. }
  133.  
  134. /*
  135.  *   checkDoor:  if the door d is open, this function silently returns
  136.  *   the room r.  Otherwise, print a message ("The door is closed.") and
  137.  *   return nil.
  138.  */
  139. checkDoor: function( d, r )
  140. {
  141.     if ( d.isopen ) return( r );
  142.     else
  143.     {
  144.     setit( d );
  145.     caps(); d.thedesc; " is closed. ";
  146.     return( nil );
  147.     }
  148. }
  149.  
  150. /*
  151.  *   checkReach: determines whether the object obj can be reached by
  152.  *   actor in location loc, using the verb v.  This routine returns true
  153.  *   if obj is a special object (numObj or strObj), if obj is in actor's
  154.  *   inventory or actor's location, or if it's in the 'reachable' list for
  155.  *   loc.  
  156.  */
  157. checkReach: function( loc, actor, v, obj )
  158. {
  159.     if ( obj=numObj or obj=strObj ) return;
  160.     if ( not ( actor.isCarrying( obj ) or obj.isIn( actor.location )))
  161.     {
  162.     if (find( loc.reachable, obj ) <> nil ) return;
  163.     "%You% can't reach "; obj.thedesc; " from "; loc.thedesc; ". ";
  164.     exit;
  165.     }
  166. }
  167.  
  168. /*
  169.  *  isIndistinguishable: function(obj1, obj2)
  170.  *
  171.  *  Returns true if the two objects are indistinguishable for the purposes
  172.  *  of listing.  The two objects are equivalent if they both have the
  173.  *  isEquivalent property set to true, they both have the same immediate
  174.  *  superclass, and their other listing properties match (in particular,
  175.  *  isworn and (islamp and islit) match for both objects).
  176.  */
  177. isIndistinguishable: function(obj1, obj2)
  178. {
  179.     return (firstsc(obj1) = firstsc(obj2)
  180.             and obj1.isworn = obj2.isworn
  181.             and ((obj1.islamp and obj1.islit)
  182.                  = (obj2.islamp and obj2.islit)));
  183. }
  184.  
  185.  
  186. /*
  187.  *  itemcnt: function( list )
  188.  *
  189.  *  Returns a count of the "listable" objects in list.  An
  190.  *  object is listable (that is, it shows up in a room's description)
  191.  *  if its isListed property is true.  This function is
  192.  *  useful for determining how many objects (if any) will be listed
  193.  *  in a room's description.  Indistinguishable items are counted as
  194.  *  a single item (two items are indistinguishable if they both have
  195.  *  the same immediate superclass, and their isEquivalent properties
  196.  *  are both true.
  197.  */
  198. itemcnt: function( list )
  199. {
  200.     local cnt, tot, i, obj, j;
  201.     tot := length(list);
  202.     cnt := 0;
  203.     i := 1;
  204.     for (i := 1, cnt := 0 ; i <= tot ; ++i)
  205.     {
  206.     /* only consider this item if it's to be listed */
  207.     obj := list[i];
  208.     if (obj.isListed)
  209.     {
  210.         /*
  211.          *   see if there are other equivalent items later in the
  212.          *   list - if so, don't count it (this ensures that each such
  213.          *   item is counted only once, since only the last such item
  214.          *   in the list will be counted) 
  215.          */
  216.         if (obj.isEquivalent)
  217.         {
  218.         local sc;
  219.         
  220.         sc := firstsc(obj);
  221.         for (j := i + 1 ; j <= tot ; ++j)
  222.         {
  223.             if (isIndistinguishable(obj, list[j]))
  224.             goto skip_this_item;
  225.         }
  226.         }
  227.         
  228.         /* count this item */
  229.         ++cnt;
  230.  
  231.     skip_this_item: ;
  232.     }
  233.     }
  234.     return cnt;
  235. }
  236.  
  237. /*
  238.  *  sayPrefixCount: function( cnt )
  239.  *
  240.  *  This function displays a count (suitable for use in listcont when
  241.  *  showing the number of equivalent items.  We display the count spelled out
  242.  *  if it's a small number, otherwise we just display the digits of the
  243.  *  number.
  244.  */
  245. sayPrefixCount: function(cnt)
  246. {
  247.     if (cnt <= 20)
  248.     say(['one' 'two' 'three' 'four' 'five'
  249.          'six' 'seven' 'eight' 'nine' 'ten'
  250.          'eleven' 'twelve' 'thirteen' 'fourteen' 'fifteen'
  251.          'sixteen' 'seventeen' 'eighteen' 'nineteen' 'twenty'][cnt]);
  252.     else
  253.     say(cnt);
  254. }
  255.  
  256. /*
  257.  *  listcont: function( obj )
  258.  *
  259.  *  This function displays the contents of an object, separated by
  260.  *  commas.  The thedesc properties of the contents are used.
  261.  *  It is up to the caller to provide the introduction to the list
  262.  *  (usually something to the effect of "The box contains" is
  263.  *  displayed before calling listcont) and finishing the
  264.  *  sentence (usually by displaying a period).  An object is listed
  265.  *  only if its isListed property is true.  If there are
  266.  *  multiple indistinguishable items in the list, the items are
  267.  *  listed only once (with the number of the items).
  268.  */
  269. listcont: function( obj )
  270. {
  271.     local i, count, tot, list, cur, disptot, prefix_count;
  272.  
  273.     list := obj.contents;
  274.     tot := length( list );
  275.     count := 0;
  276.     disptot := itemcnt( list );
  277.     for (i := 1 ; i <= tot ; ++i)
  278.     {
  279.         cur := list[i];
  280.         if ( cur.isListed )
  281.         {
  282.         /* presume there is only one such object */
  283.         prefix_count := 1;
  284.         
  285.         /*
  286.          *   if this is one of more than one equivalent items, list
  287.          *   it only if it's the first one, and show the number of
  288.          *   such items along with the first one 
  289.          */
  290.         if (cur.isEquivalent)
  291.         {
  292.         local before, after;
  293.         local j;
  294.         local sc;
  295.  
  296.         sc := firstsc(cur);
  297.         for (before := after := 0, j := 1 ; j <= tot ; ++j)
  298.         {
  299.             if (isIndistinguishable(cur, list[j]))
  300.             {
  301.             if (j < i)
  302.             {
  303.                 /*
  304.                  *   note that objects precede this one, and
  305.                  *   then look no further, since we're just
  306.                  *   going to skip this item anyway
  307.                  */
  308.                 ++before;
  309.                 break;
  310.             }
  311.             else
  312.                 ++after;
  313.             }
  314.         }
  315.  
  316.         /*
  317.          *   if there are multiple such objects, and this is the
  318.          *   first such object, list it with the count prefixed;
  319.          *   if there are multiple and this isn't the first one,
  320.          *   skip it; otherwise, go on as normal 
  321.          */
  322.         if (before = 0)
  323.             prefix_count := after;
  324.         else
  325.             continue;
  326.         }
  327.  
  328.             if ( count > 0 )
  329.             {
  330.                 if ( count+1 < disptot )
  331.                     ", ";
  332.                 else if (count = 1)
  333.                     " and ";
  334.                 else
  335.                     ", and ";
  336.             }
  337.  
  338.         /* list the object, along with the number of such items */
  339.         if (prefix_count = 1)
  340.         cur.adesc;
  341.         else
  342.         {
  343.         sayPrefixCount(prefix_count); " ";
  344.         cur.pluraldesc;
  345.         }
  346.  
  347.         /* show any additional information about the item */
  348.             if ( cur.isworn ) " (being worn)";
  349.             if ( cur.islamp and cur.islit ) " (providing light)";
  350.             count := count + 1;
  351.         }
  352.     }
  353. }
  354.  
  355. /*
  356.  *   showcontcont:  list the contents of the object, plus the contents of
  357.  *   an fixeditem's contained by the object.  A complete sentence is shown.
  358.  *   This is an internal routine used by listcontcont and listfixedcontcont.
  359.  */
  360. showcontcont: function( obj )
  361. {
  362.     if (itemcnt( obj.contents ))
  363.     {
  364.         if (obj.issurface)
  365.         {
  366.         if (obj.isqsurface)
  367.         {
  368.         "Sitting on "; obj.thedesc;" is "; listcont( obj );
  369.         ". ";
  370.         }
  371.         }
  372.         else if ( obj.contentsVisible and not obj.isqcontainer )
  373.         {
  374.             caps();
  375.             obj.thedesc; " seems to contain ";
  376.             listcont( obj );
  377.             ". ";
  378.         }
  379.     }
  380.     if ( obj.contentsVisible and not obj.isqcontainer )
  381.         listfixedcontcont( obj );
  382. }
  383.  
  384. /*
  385.  *  listfixedcontcont: function( obj )
  386.  *
  387.  *  List the contents of the contents of any fixeditem objects
  388.  *  in the contents list of the object obj.  This routine
  389.  *  makes sure that all objects that can be taken are listed somewhere
  390.  *  in a room's description.  This routine recurses down the contents
  391.  *  tree, following each branch until either something has been listed
  392.  *  or the branch ends without anything being listable.  This routine
  393.  *  displays a complete sentence, so no introductory or closing text
  394.  *  is needed.
  395.  */
  396. listfixedcontcont: function( obj )
  397. {
  398.     local list, i, tot, thisobj;
  399.  
  400.     list := obj.contents;
  401.     tot := length( list );
  402.     i := 1;
  403.     while ( i <= tot )
  404.     {
  405.         thisobj := list[i];
  406.         if ( thisobj.isfixed and thisobj.contentsVisible and
  407.       not thisobj.isqcontainer )
  408.             showcontcont( thisobj );
  409.     i := i + 1;
  410.     }
  411. }
  412.  
  413. /*
  414.  *  listcontcont: function( obj )
  415.  *
  416.  *  This function lists the contents of the contents of an object.
  417.  *  It displays full sentences, so no introductory or closing text
  418.  *  is required.  Any item in the contents list of the object
  419.  *  obj whose contentsVisible property is true has
  420.  *  its contents listed.  An Object whose isqcontainer or
  421.  *  isqsurface property is true will not have its
  422.  *  contents listed.
  423.  */
  424. listcontcont: function( obj )
  425. {
  426.     local list, i, tot;
  427.     list := obj.contents;
  428.     tot := length( list );
  429.     i := 1;
  430.     while ( i <= tot )
  431.     {
  432.         showcontcont( list[i] );
  433.     i := i + 1;
  434.     }
  435. }
  436.  
  437. /*
  438.  *  scoreStatus: function(points, turns)
  439.  *
  440.  *  This function updates the score on the status line.  This implementation
  441.  *  simply calls the built-in function setscore() with the same information.
  442.  *  The call to setscore() has been isolated in this function to make it
  443.  *  easier to replace with a customized version; to replace the status line
  444.  *  score display, simply replace this routine.
  445.  */
  446. scoreStatus: function(points, turns)
  447. {
  448.     setscore(points, turns);
  449. }
  450.  
  451. /*
  452.  *  turncount: function( parm )
  453.  *
  454.  *  This function can be used as a daemon (normally set up in the init
  455.  *  function) to update the turn counter after each turn.  This routine
  456.  *  increments global.turnsofar, and then calls setscore to
  457.  *  update the status line with the new turn count.
  458.  */
  459. turncount: function( parm )
  460. {
  461.     incturn();
  462.     global.turnsofar := global.turnsofar + 1;
  463.     scoreStatus( global.score, global.turnsofar );
  464. }
  465.  
  466. /*
  467.  *  addweight: function( list )
  468.  *
  469.  *  Adds the weights of the objects in list and returns the sum.
  470.  *  The weight of an object is given by its weight property.  This
  471.  *  routine includes the weights of all of the contents of each object,
  472.  *  and the weights of their contents, and so forth.
  473.  */
  474. addweight: function( l )
  475. {
  476.     local tot, i, c, totweight;
  477.  
  478.     tot := length( l );
  479.     i := 1;
  480.     totweight := 0;
  481.     while ( i <= tot )
  482.     {
  483.         c := l[i];
  484.         totweight := totweight + c.weight;
  485.         if (length( c.contents ))
  486.             totweight := totweight + addweight( c.contents );
  487.         i := i + 1;
  488.     }
  489.     return( totweight );
  490. }
  491.  
  492. /*
  493.  *  addbulk: function( list )
  494.  *
  495.  *  This function returns the sum of the bulks (given by the bulk
  496.  *  property) of each object in list.  The value returned includes
  497.  *  only the bulk of each object in the list, and not of the contents
  498.  *  of the objects, as it is assumed that an object does not change in
  499.  *  size when something is put inside it.  You can easily change this
  500.  *  assumption for special objects (such as a bag that stretches as
  501.  *  things are put inside) by writing an appropriate bulk method
  502.  *  for that object.
  503.  */
  504. addbulk: function( list )
  505. {
  506.     local i, tot, totbulk, rem, cur;
  507.  
  508.     tot := length( list );
  509.     i := 1;
  510.     totbulk := 0;
  511.     while( i <= tot )
  512.     {
  513.         cur := list[i];
  514.         if ( not cur.isworn )
  515.             totbulk := totbulk + cur.bulk;
  516.         i := i + 1;
  517.     }
  518.     return( totbulk );
  519. }
  520.  
  521. /*
  522.  *  incscore: function( amount )
  523.  *
  524.  *  Adds amount to the total score, and updates the status line
  525.  *  to reflect the new score.  The total score is kept in global.score.
  526.  *  Always use this routine rather than changing global.score
  527.  *  directly, since this routine ensures that the status line is
  528.  *  updated with the new value.
  529.  */
  530. incscore: function( amount )
  531. {
  532.     global.score := global.score + amount;
  533.     scoreStatus( global.score, global.turnsofar );
  534. }
  535.  
  536. /*
  537.  *  initSearch: function
  538.  *
  539.  *  Initializes the containers of objects with a searchLoc, underLoc,
  540.  *  and behindLoc by setting up searchCont, underCont, and
  541.  *  behindCont lists, respectively.  You should call this function once in
  542.  *  your preinit (or init, if you prefer) function to ensure that
  543.  *  the underable, behindable, and searchable objects are set up correctly.
  544.  *  
  545.  *  As a bonus, we take this opportunity to initialize global.floatingList
  546.  *  with a list of all objects of class floatingItem.  It is necessary to
  547.  *  initialize this list, so that validDoList and validIoList include objects
  548.  *  with variable location properties.  Note that, for this to work,
  549.  *  all objects with variable location properties must be declared
  550.  *  to be of class floatingItem.
  551.  */
  552. initSearch: function
  553. {
  554.     local o;
  555.     
  556.     o := firstobj(hiddenItem);
  557.     while (o <> nil)
  558.     {
  559.     if (o.searchLoc)
  560.         o.searchLoc.searchCont := o.searchLoc.searchCont + o;
  561.     else if (o.underLoc)
  562.         o.underLoc.underCont := o.underLoc.underCont + o;
  563.     else if (o.behindLoc)
  564.         o.behindLoc.behindCont := o.behindLoc.behindCont + o;
  565.     o := nextobj(o, hiddenItem);
  566.     }
  567.     
  568.     global.floatingList := [];
  569.     for (o := firstobj(floatingItem) ; o ; o := nextobj(o, floatingItem))
  570.     global.floatingList += o;
  571. }
  572.  
  573. /*
  574.  *  reachableList: function
  575.  *
  576.  *  Returns a list of all the objects reachable from a given object.
  577.  *  That is, if the object is open or is not an openable, it returns the
  578.  *  contents of the object, plus the reachableList result of each object;
  579.  *  if the object is closed, it returns an empty list.
  580.  */
  581. reachableList: function(obj)
  582. {
  583.     local ret := [];
  584.     local i, lst, len;
  585.     
  586.     if (not isclass(obj, openable)
  587.     or (isclass(obj, openable) and obj.isopen))
  588.     {
  589.     lst := obj.contents;
  590.     len := length(lst);
  591.     ret += lst;
  592.     for (i := 1 ; i <= len ; ++i)
  593.         ret += reachableList(lst[i]);
  594.     }
  595.  
  596.     return(ret);
  597. }
  598.  
  599. /*
  600.  *  visibleList: function
  601.  *
  602.  *  This function is similar to reachableList, but returns the
  603.  *  list of objects visible within a given object.
  604.  */
  605. visibleList: function(obj)
  606. {
  607.     local ret := [];
  608.     local i, lst, len;
  609.     
  610.     if (not isclass(obj, openable)
  611.     or (isclass(obj, openable) and obj.isopen)
  612.     or obj.contentsVisible)
  613.     {
  614.     lst := obj.contents;
  615.     len := length(lst);
  616.     ret += lst;
  617.     for (i := 1 ; i <= len ; ++i)
  618.         ret += visibleList(lst[i]);
  619.     }
  620.  
  621.     return(ret);
  622. }
  623.  
  624. /*
  625.  *  nestedroom: room
  626.  *
  627.  *  A special kind of room that is inside another room; chairs and
  628.  *  some types of vehicles, such as inflatable rafts, fall into this
  629.  *  category.  Note that a room can be within another room without
  630.  *  being a nestedroom, simply by setting its location property
  631.  *  to another room.  The nestedroom is different from an ordinary
  632.  *  room, though, in that it's an "open" room; that is, when inside it,
  633.  *  the actor is still really inside the enclosing room for purposes of
  634.  *  descriptions.  Hence, the player sees "Laboratory, in the chair."
  635.  *  In addition, a nestedroom is an object in its own right,
  636.  *  visible to the player; for example, a chair is an object in a
  637.  *  room in addition to being a room itself.  The statusPrep
  638.  *  property displays the preposition in the status description; by
  639.  *  default, it will be "in," but some subclasses and instances
  640.  *  will want to change this to a more appropriate preposition.
  641.  *  outOfPrep is used to report what happens when the player
  642.  *  gets out of the object:  it should be "out of" or "off of" as
  643.  *  appropriate to this object.
  644.  */
  645. class nestedroom: room
  646.     statusPrep = "in"
  647.     outOfPrep = "out of"
  648.     islit =
  649.     {
  650.         if ( self.location ) return( self.location.islit );
  651.         return( nil );
  652.     }
  653.     statusLine =
  654.     {
  655.     "<<self.location.sdesc>>, <<self.statusPrep>> <<self.thedesc>>\n\t";
  656.     }
  657.     lookAround( verbosity ) =
  658.     {
  659.         self.statusLine;
  660.     self.location.nrmLkAround( verbosity );
  661.     }
  662.     roomDrop( obj ) =
  663.     {
  664.         if ( self.location = nil or self.isdroploc ) pass roomDrop;
  665.     else self.location.roomDrop( obj );
  666.     }
  667. ;
  668.  
  669. /*
  670.  *  chairitem: fixeditem, nestedroom, surface
  671.  *
  672.  *  Acts like a chair:  actors can sit on the object.  While sitting
  673.  *  on the object, an actor can't go anywhere until standing up, and
  674.  *  can only reach objects that are on the chair and in the chair's
  675.  *  reachable list.  By default, nothing is in the reachable
  676.  *  list.  Note that there is no real distinction made between chairs
  677.  *  and beds, so you can sit or lie on either; the only difference is
  678.  *  the message displayed describing the situation.
  679.  */
  680. class chairitem: fixeditem, nestedroom, surface
  681.     reachable = ([] + self) // list of all containers reachable from here;
  682.                             //  normally, you can only reach carried items
  683.                             //  from a chair, but this makes special allowances
  684.     ischair = true          // it is a chair by default; for beds or other
  685.                             //  things you lie down on, make it false
  686.     outOfPrep = "out of"
  687.     roomAction( actor, v, dobj, prep, io ) =
  688.     {
  689.         if ( dobj<>nil and v<>inspectVerb )
  690.             checkReach( self, actor, v, dobj );
  691.         if ( io<>nil and v<>askVerb and v<>tellVerb )
  692.             checkReach( self, actor, v, io );
  693.     pass roomAction;
  694.     }
  695.     enterRoom( actor ) = {}
  696.     noexit =
  697.     {
  698.         "%You're% not going anywhere until %you%
  699.         get%s% <<outOfPrep>> <<thedesc>>. ";
  700.         return( nil );
  701.     }
  702.     verDoBoard( actor ) = { self.verDoSiton( actor ); }
  703.     doBoard( actor ) = { self.doSiton( actor ); }
  704.     verDoSiton( actor ) =
  705.     {
  706.         if ( actor.location = self )
  707.         {
  708.             "%You're% already on "; self.thedesc; "! ";
  709.         }
  710.     }
  711.     doSiton( actor ) =
  712.     {
  713.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  714.         actor.travelTo( self );
  715.     }
  716.     verDoLieon( actor ) =
  717.     {
  718.         self.verDoSiton( actor );
  719.     }
  720.     doLieon( actor ) =
  721.     {
  722.         self.doSiton( actor );
  723.     }
  724. ;
  725.  
  726. /*
  727.  *  beditem: chairitem
  728.  *
  729.  *  This object is the same as a chairitem, except that the player
  730.  *  is described as lying on, rather than sitting in, the object.
  731.  */
  732. class beditem: chairitem
  733.     ischair = nil
  734.     isbed = true
  735.     sdesc = "bed"
  736.     statusPrep = "on"
  737.     outOfPrep = "out of"
  738.     doLieon(actor) =
  739.     {
  740.         "Okay, %you're% now lying on <<self.thedesc>>.";
  741.     actor.travelTo(self);
  742.     }
  743. ;
  744.     
  745. /*
  746.  *  floatingItem: object
  747.  *
  748.  *  This class doesn't do anything apart from mark an object as having a
  749.  *  variable location property.  It is necessary to mark all such
  750.  *  items by making them a member of this class, so that the objects are
  751.  *  added to global.floatingList, which is necessary so that floating
  752.  *  objects are included in validDoList and validIoList values (see
  753.  *  the deepverb class for a description of these methods).
  754.  */
  755. class floatingItem: object
  756. ;
  757.  
  758. /*
  759.  *  thing: object
  760.  *
  761.  *  The basic class for objects in a game.  The property contents
  762.  *  is a list that specifies what is in the object; this property is
  763.  *  automatically set up by the system after the game is compiled to
  764.  *  contain a list of all objects that have this object as their
  765.  *  location property.  The contents property is kept
  766.  *  consistent with the location properties of referenced objects
  767.  *  by the moveInto method; always use moveInto rather than
  768.  *  directly setting a location property for this reason.  The
  769.  *  adesc method displays the name of the object with an indefinite
  770.  *  article; the default is to display "a" followed by the sdesc,
  771.  *  but objects that need a different indefinite article (such as "an"
  772.  *  or "some") should override this method.  Likewise, thedesc
  773.  *  displays the name with a definite article; by default, thedesc
  774.  *  displays "the" followed by the object's sdesc.  The sdesc
  775.  *  simply displays the object's name ("short description") without
  776.  *  any articles.  The ldesc is the long description, normally
  777.  *  displayed when the object is examined by the player; by default,
  778.  *  the ldesc displays "It looks like an ordinary sdesc."
  779.  *  The isIn(object) method returns true if the
  780.  *  object's location is the specified object or the object's
  781.  *  location is an object whose contentsVisible property is
  782.  *  true and that object's isIn(object) method is
  783.  *  true.  Note that if isIn is true, it doesn't
  784.  *  necessarily mean the object is reachable, because isIn is
  785.  *  true if the object is merely visible within the location.
  786.  *  The moveInto(object) method moves the object to be inside
  787.  *  the specified object.  To make an object disappear, move it
  788.  *  into nil.
  789.  */
  790. class thing: object
  791.     weight = 0
  792.     bulk = 1
  793.     isListed = true         // shows up in room/inventory listings
  794.     contents = []           // set up automatically by system - do not set
  795.     verGrab( obj ) = {}
  796.     Grab( obj ) = {}
  797.     adesc =
  798.     {
  799.         "a "; self.sdesc;   // default is "a <name>"; "self" is current object
  800.     }
  801.     pluraldesc =            // default is to add "s" to the sdesc
  802.     {
  803.     self.sdesc; "s";
  804.     }
  805.     thedesc =
  806.     {
  807.         "the "; self.sdesc; // default is "the <name>"
  808.     }
  809.     multisdesc = { self.sdesc; }
  810.     ldesc = { "It looks like an ordinary "; self.sdesc; " to %me%."; }
  811.     readdesc = { "%You% can't read "; self.adesc; ". "; }
  812.     actorAction( v, d, p, i ) =
  813.     {
  814.         "You have lost your mind. ";
  815.         exit;
  816.     }
  817.     contentsVisible = { return( true ); }
  818.     contentsReachable = { return( true ); }
  819.     isIn( obj ) =
  820.     {
  821.         local myloc;
  822.  
  823.         myloc := self.location;
  824.         if ( myloc )
  825.         {
  826.             if ( myloc = obj ) return( true );
  827.             if ( myloc.contentsVisible ) return( myloc.isIn( obj ));
  828.         }
  829.         return( nil );
  830.     }
  831.     moveInto( obj ) =
  832.     {
  833.         local loc;
  834.  
  835.     /*
  836.      *   For the object containing me, and its container, and so forth,
  837.      *   tell it via a Grab message that I'm going away.
  838.      */
  839.     loc := self.location;
  840.     while ( loc )
  841.     {
  842.         loc.Grab( self );
  843.         loc := loc.location;
  844.     }
  845.  
  846.         if ( self.location )
  847.             self.location.contents := self.location.contents - self;
  848.         self.location := obj;
  849.         if ( obj ) obj.contents := obj.contents + self;
  850.     }
  851.     verDoSave( actor ) =
  852.     {
  853.         "Please specify the name of the game to save in double quotes,
  854.         for example, SAVE \"GAME1\". ";
  855.     }
  856.     verDoRestore( actor ) =
  857.     {
  858.         "Please specify the name of the game to restore in double quotes,
  859.         for example, RESTORE \"GAME1\". ";
  860.     }
  861.     verDoScript( actor ) =
  862.     {
  863.         "You should type the name of a file to write the transcript to
  864.         in quotes, for example, SCRIPT \"LOG1\". ";
  865.     }
  866.     verDoSay( actor ) =
  867.     {
  868.         "You should say what you want to say in double quotes, for example,
  869.         SAY \"HELLO\". ";
  870.     }
  871.     verDoPush( actor ) =
  872.     {
  873.         "Pushing "; self.thedesc; " doesn't do anything. ";
  874.     }
  875.     verDoWear( actor ) =
  876.     {
  877.         "%You% can't wear "; self.thedesc; ". ";
  878.     }
  879.     verDoTake( actor ) =
  880.     {
  881.         if ( self.location = actor )
  882.         {
  883.             "%You% already %have% "; self.thedesc; "! ";
  884.         }
  885.         else self.verifyRemove( actor );
  886.     }
  887.     verifyRemove( actor ) =
  888.     {
  889.       /*
  890.      *   Check with each container to make sure that the container
  891.      *   doesn't object to the object's removal.
  892.      */
  893.         local loc;
  894.  
  895.         loc := self.location;
  896.         while ( loc )
  897.         {
  898.             if ( loc <> actor ) loc.verGrab( self );
  899.             loc := loc.location;
  900.         }
  901.     }
  902.     isVisible( vantage ) =
  903.     {
  904.         local loc;
  905.  
  906.         loc := self.location;
  907.         if ( loc = nil ) return( nil );
  908.  
  909.     /*
  910.      *   if the vantage is inside me, and my contents are visible,
  911.      *   I'm visible 
  912.      */
  913.     if (vantage.location = self and self.contentsVisible)
  914.         return true;
  915.  
  916.         /* if I'm in the vantage, I'm visible */
  917.         if ( loc = vantage ) return( true );
  918.  
  919.         /*
  920.          *   if its location's contents are visible, and its location is
  921.          *   itself visible, it's visible
  922.          */
  923.         if ( loc.contentsVisible and loc.isVisible( vantage )) return( true );
  924.  
  925.         /*
  926.          *   If the vantage has a location, and the vantage's location's
  927.          *   contents are visible (if you can see me I can see you), and
  928.          *   the object is visible from the vantage's location, the object
  929.          *   is visible
  930.          */
  931.         if ( vantage.location <> nil and vantage.location.contentsVisible and
  932.          self.isVisible( vantage.location ))
  933.             return( true );
  934.  
  935.         /* all tests failed:  it's not visible */
  936.         return( nil );
  937.     }
  938.     cantReach( actor ) =
  939.     {
  940.         if ( self.location = nil )
  941.         {
  942.             if ( actor.location.location )
  943.                "%You% can't reach that from << actor.location.thedesc >>. ";
  944.             return;
  945.         }
  946.         if ( not self.location.isopenable or self.location.isopen )
  947.             self.location.cantReach( actor );
  948.         else "%You%'ll have to open << self.location.thedesc >> first. ";
  949.     }
  950.     isReachable( actor ) =
  951.     {
  952.         local loc;
  953.  
  954.         /* if the object is in the room's 'reachable' list, it's reachable */
  955.         if (find( actor.location.reachable, self ) <> nil )
  956.             return( true );
  957.  
  958.         /*
  959.          *   If the object's container's contents are reachable, and the
  960.          *   container is reachable, the object is reachable.
  961.          */
  962.         loc := self.location;
  963.     if (find( actor.location.reachable, self ) <> nil )
  964.         return( true );
  965.     if ( loc = nil ) return( nil );
  966.     if ( loc = actor or loc = actor.location ) return( true );
  967.     if ( loc.contentsReachable )
  968.         return( loc.isReachable( actor ));
  969.     return( nil );
  970.         return( nil );
  971.     }
  972.     doTake( actor ) =
  973.     {
  974.         local totbulk, totweight;
  975.  
  976.         totbulk := addbulk( actor.contents ) + self.bulk;
  977.         totweight := addweight( actor.contents );
  978.         if ( not actor.isCarrying( self ))
  979.             totweight := totweight + self.weight + addweight(self.contents);
  980.  
  981.         if ( totweight > actor.maxweight )
  982.             "%Your% load is too heavy. ";
  983.         else if ( totbulk > actor.maxbulk )
  984.             "%You've% already got %your% hands full. ";
  985.         else
  986.         {
  987.             self.moveInto( actor );
  988.             "Taken. ";
  989.         }
  990.     }
  991.     verDoDrop( actor ) =
  992.     {
  993.         if ( not actor.isCarrying( self ))
  994.         {
  995.             "%You're% not carrying "; self.thedesc; "! ";
  996.         }
  997.         else self.verifyRemove( actor );
  998.     }
  999.     doDrop( actor ) =
  1000.     {
  1001.         actor.location.roomDrop( self );
  1002.     }
  1003.     verDoUnwear( actor ) =
  1004.     {
  1005.         "%You're% not wearing "; self.thedesc; "! ";
  1006.     }
  1007.     verIoPutIn( actor ) =
  1008.     {
  1009.         "%You% can't put anything into "; self.thedesc; ". ";
  1010.     }
  1011.     circularMessage(io) =
  1012.     {
  1013.         local cont;
  1014.  
  1015.     "%You% can't put <<thedesc>> in <<io.thedesc>>, because
  1016.     <<io.thedesc>> is <<io.location = self ? "already" : ""
  1017.         >> <<io.location.issurface ? "on" : "in">> <<io.location.thedesc>>";
  1018.     for (cont := io.location ; cont <> self ; cont := cont.location)
  1019.     {
  1020.         ", which is ";
  1021.             if (cont.location = self) "already ";
  1022.             "<<cont.location.issurface ? "on" : "in"
  1023.             >> <<cont.location.thedesc>>";
  1024.     }
  1025.     ".";
  1026.     }
  1027.     verDoPutIn( actor, io ) =
  1028.     {
  1029.         if ( io = nil ) return;
  1030.  
  1031.         if ( self.location = io )
  1032.         {
  1033.             caps(); self.thedesc; " is already in "; io.thedesc; "! ";
  1034.         }
  1035.         else if (io = self)
  1036.         {
  1037.             "%You% can't put "; self.thedesc; " in itself! ";
  1038.         }
  1039.         else if (io.isIn(self))
  1040.         self.circularMessage(io);
  1041.         else
  1042.             self.verifyRemove( actor );
  1043.     }
  1044.     doPutIn( actor, io ) =
  1045.     {
  1046.         self.moveInto( io );
  1047.         "Done. ";
  1048.     }
  1049.     verIoPutOn( actor ) =
  1050.     {
  1051.         "There's no good surface on "; self.thedesc; ". ";
  1052.     }
  1053.     verDoPutOn( actor, io ) =
  1054.     {
  1055.         if ( io = nil ) return;
  1056.  
  1057.         if ( self.location = io )
  1058.         {
  1059.             caps(); self.thedesc; " is already on "; io.thedesc; "! ";
  1060.         }
  1061.     else if (io = self)
  1062.         {
  1063.             "%You% can't put "; self.thedesc; " on itself! ";
  1064.         }
  1065.     else if (io.isIn(self))
  1066.         self.circularMessage(io);
  1067.         else
  1068.         self.verifyRemove( actor );
  1069.     }
  1070.     doPutOn( actor, io ) =
  1071.     {
  1072.         self.moveInto( io );
  1073.         "Done. ";
  1074.     }
  1075.     verIoTakeOut( actor ) = {}
  1076.     ioTakeOut( actor, dobj ) =
  1077.     {
  1078.         dobj.doTakeOut( actor, self );
  1079.     }
  1080.     verDoTakeOut( actor, io ) =
  1081.     {
  1082.         if ( io <> nil and not self.isIn( io ))
  1083.         {
  1084.             caps(); self.thedesc; " isn't in "; io.thedesc; ". ";
  1085.         }
  1086.     self.verDoTake(actor);         /* ensure object can be taken at all */
  1087.     }
  1088.     doTakeOut( actor, io ) =
  1089.     {
  1090.         self.doTake( actor );
  1091.     }
  1092.     verIoTakeOff( actor ) = {}
  1093.     ioTakeOff( actor, dobj ) =
  1094.     {
  1095.         dobj.doTakeOff( actor, self );
  1096.     }
  1097.     verDoTakeOff( actor, io ) =
  1098.     {
  1099.         if ( io <> nil and not self.isIn( io ))
  1100.         {
  1101.             caps(); self.thedesc; " isn't on "; io.thedesc; "! ";
  1102.         }
  1103.     self.verDoTake(actor);         /* ensure object can be taken at all */
  1104.     }
  1105.     doTakeOff( actor, io ) =
  1106.     {
  1107.         self.doTake( actor );
  1108.     }
  1109.     verIoPlugIn( actor ) =
  1110.     {
  1111.         "%You% can't plug anything into "; self.thedesc; ". ";
  1112.     }
  1113.     verDoPlugIn( actor, io ) =
  1114.     {
  1115.         "%You% can't plug "; self.thedesc; " into anything. ";
  1116.     }
  1117.     verIoUnplugFrom( actor ) =
  1118.     {
  1119.         "It's not plugged into "; self.thedesc; ". ";
  1120.     }
  1121.     verDoUnplugFrom( actor, io ) =
  1122.     {
  1123.         if ( io <> nil ) { "It's not plugged into "; io.thedesc; ". "; }
  1124.     }
  1125.     verDoLookin( actor ) =
  1126.     {
  1127.         "There's nothing in "; self.thedesc; ". ";
  1128.     }
  1129.     thrudesc = { "%You% can't see much through << thedesc >>.\n"; }
  1130.     verDoLookthru( actor ) =
  1131.     {
  1132.         "%You% can't see anything through "; self.thedesc; ". ";
  1133.     }
  1134.     verDoLookunder( actor ) =
  1135.     {
  1136.         "There's nothing under "; self.thedesc; ". ";
  1137.     }
  1138.     verDoInspect( actor ) = {}
  1139.     doInspect( actor ) =
  1140.     {
  1141.         self.ldesc;
  1142.     }
  1143.     verDoRead( actor ) =
  1144.     {
  1145.         "I don't know how to read "; self.thedesc; ". ";
  1146.     }
  1147.     verDoLookbehind( actor ) =
  1148.     {
  1149.         "There's nothing behind "; self.thedesc; ". ";
  1150.     }
  1151.     verDoTurn( actor ) =
  1152.     {
  1153.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1154.     }
  1155.     verDoTurnWith( actor, io ) =
  1156.     {
  1157.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1158.     }
  1159.     verDoTurnTo( actor, io ) =
  1160.     {
  1161.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1162.     }
  1163.     verIoTurnTo( actor ) =
  1164.     {
  1165.         "I don't know how to do that. ";
  1166.     }
  1167.     verDoTurnon( actor ) =
  1168.     {
  1169.         "I don't know how to turn "; self.thedesc; " on. ";
  1170.     }
  1171.     verDoTurnoff( actor ) =
  1172.     {
  1173.         "I don't know how to turn "; self.thedesc; " off. ";
  1174.     }
  1175.     verIoAskAbout( actor ) = {}
  1176.     ioAskAbout( actor, dobj ) =
  1177.     {
  1178.         dobj.doAskAbout( actor, self );
  1179.     }
  1180.     verDoAskAbout( actor, io ) =
  1181.     {
  1182.         "Surely, %you% can't think "; self.thedesc; " knows anything
  1183.         about it! ";
  1184.     }
  1185.     verIoTellAbout( actor ) = {}
  1186.     ioTellAbout( actor, dobj ) =
  1187.     {
  1188.         dobj.doTellAbout( actor, self );
  1189.     }
  1190.     verDoTellAbout( actor, io ) =
  1191.     {
  1192.         "It doesn't look as though "; self.thedesc; " is interested. ";
  1193.     }
  1194.     verDoUnboard( actor ) =
  1195.     {
  1196.         if ( actor.location <> self )
  1197.         {
  1198.             "%You're% not in "; self.thedesc; "! ";
  1199.         }
  1200.         else if ( self.location=nil )
  1201.         {
  1202.             "%You% can't get out of "; self.thedesc; "! ";
  1203.         }
  1204.     }
  1205.     doUnboard( actor ) =
  1206.     {
  1207.         if ( self.fastenitem )
  1208.     {
  1209.         "%You%'ll have to unfasten "; actor.location.fastenitem.thedesc;
  1210.         " first. ";
  1211.     }
  1212.     else
  1213.     {
  1214.             "Okay, %you're% no longer in "; self.thedesc; ". ";
  1215.             self.leaveRoom( actor );
  1216.         actor.moveInto( self.location );
  1217.     }
  1218.     }
  1219.     verDoAttackWith( actor, io ) =
  1220.     {
  1221.         "Attacking "; self.thedesc; " doesn't appear productive. ";
  1222.     }
  1223.     verIoAttackWith( actor ) =
  1224.     {
  1225.         "It's not very effective to attack with "; self.thedesc; ". ";
  1226.     }
  1227.     verDoEat( actor ) =
  1228.     {
  1229.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1230.     }
  1231.     verDoDrink( actor ) =
  1232.     {
  1233.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1234.     }
  1235.     verDoGiveTo( actor, io ) =
  1236.     {
  1237.         if ( not actor.isCarrying( self ))
  1238.         {
  1239.             "%You're% not carrying "; self.thedesc; ". ";
  1240.         }
  1241.         else self.verifyRemove( actor );
  1242.     }
  1243.     doGiveTo( actor, io ) =
  1244.     {
  1245.         self.moveInto( io );
  1246.         "Done. ";
  1247.     }
  1248.     verDoPull( actor ) =
  1249.     {
  1250.         "Pulling "; self.thedesc; " doesn't have any effect. ";
  1251.     }
  1252.     verDoThrowAt( actor, io ) =
  1253.     {
  1254.         if ( not actor.isCarrying( self ))
  1255.         {
  1256.             "%You're% not carrying "; self.thedesc; ". ";
  1257.         }
  1258.         else self.verifyRemove( actor );
  1259.     }
  1260.     doThrowAt( actor, io ) =
  1261.     {
  1262.         "%You% miss%es%. ";
  1263.         self.moveInto( actor.location );
  1264.     }
  1265.     verIoThrowAt( actor ) =
  1266.     {
  1267.         if ( actor.isCarrying( self ))
  1268.         {
  1269.             "%You% could at least drop "; self.thedesc; " first. ";
  1270.         }
  1271.     }
  1272.     ioThrowAt( actor, dobj ) =
  1273.     {
  1274.         dobj.doThrowAt( actor, self );
  1275.     }
  1276.     verDoThrowTo( actor, io ) =
  1277.     {
  1278.         if ( not actor.isCarrying( self ))
  1279.         {
  1280.             "%You're% not carrying "; self.thedesc; ". ";
  1281.         }
  1282.         else self.verifyRemove( actor );
  1283.     }
  1284.     doThrowTo( actor, io ) =
  1285.     {
  1286.         "%You% miss%es%. ";
  1287.         self.moveInto( actor.location );
  1288.     }
  1289.     verDoThrow( actor ) =
  1290.     {
  1291.         if ( not actor.isCarrying( self ))
  1292.         {
  1293.             "%You're% not carrying "; self.thedesc; ". ";
  1294.         }
  1295.         else self.verifyRemove( actor );
  1296.     }
  1297.     doThrow( actor ) =
  1298.     {
  1299.         "Thrown. ";
  1300.         self.moveInto( actor.location );
  1301.     }
  1302.     verDoShowTo( actor, io ) =
  1303.     {
  1304.     }
  1305.     doShowTo( actor, io ) =
  1306.     {
  1307.         if ( io <> nil ) { caps(); io.thedesc; " isn't impressed. "; }
  1308.     }
  1309.     verIoShowTo( actor ) =
  1310.     {
  1311.         caps(); self.thedesc; " isn't impressed. ";
  1312.     }
  1313.     verDoClean( actor ) =
  1314.     {
  1315.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1316.     }
  1317.     verDoCleanWith( actor, io ) = {}
  1318.     doCleanWith( actor, io ) =
  1319.     {
  1320.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1321.     }
  1322.     verDoMove( actor ) =
  1323.     {
  1324.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1325.     }
  1326.     verDoMoveTo( actor, io ) =
  1327.     {
  1328.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1329.     }
  1330.     verIoMoveTo( actor ) =
  1331.     {
  1332.         "That doesn't get us anywhere. ";
  1333.     }
  1334.     verDoMoveWith( actor, io ) =
  1335.     {
  1336.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1337.     }
  1338.     verIoMoveWith( actor ) =
  1339.     {
  1340.         caps(); self.thedesc; " doesn't seem to help. ";
  1341.     }
  1342.     verDoTypeOn( actor, io ) =
  1343.     {
  1344.         "You should say what you want to type in double quotes, for
  1345.         example, TYPE \"HELLO\" ON KEYBOARD. ";
  1346.     }
  1347.     verDoTouch( actor ) =
  1348.     {
  1349.         "Touching "; self.thedesc; " doesn't seem to have any effect. ";
  1350.     }
  1351.     verDoPoke( actor ) =
  1352.     {
  1353.         "Poking "; self.thedesc; " doesn't seem to have any effect. ";
  1354.     }
  1355.     verDoBreak(actor) = {}
  1356.     doBreak(actor) =
  1357.     {
  1358.     "You'll have to tell me how to do that.";
  1359.     }
  1360.     genMoveDir = { "%You% can't seem to do that. "; }
  1361.     verDoMoveN( actor ) = { self.genMoveDir; }
  1362.     verDoMoveS( actor ) = { self.genMoveDir; }
  1363.     verDoMoveE( actor ) = { self.genMoveDir; }
  1364.     verDoMoveW( actor ) = { self.genMoveDir; }
  1365.     verDoMoveNE( actor ) = { self.genMoveDir; }
  1366.     verDoMoveNW( actor ) = { self.genMoveDir; }
  1367.     verDoMoveSE( actor ) = { self.genMoveDir; }
  1368.     verDoMoveSW( actor ) = { self.genMoveDir; }
  1369.     verDoSearch( actor ) =
  1370.     {
  1371.         "%You% find%s% nothing of interest. ";
  1372.     }
  1373.  
  1374.     /* on dynamic construction, move into my contents list */
  1375.     construct =
  1376.     {
  1377.     self.moveInto(location);
  1378.     }
  1379.  
  1380.     /* on dynamic destruction, move out of contents list */
  1381.     destruct =
  1382.     {
  1383.     self.moveInto(nil);
  1384.     }
  1385.  
  1386.     /*
  1387.      *   Make it so that the player can give a command to an actor only
  1388.      *   if an actor is reachable in the normal manner.  This method
  1389.      *   returns true when 'self' can be given a command by the player. 
  1390.      */
  1391.     validActor = (self.isReachable(Me))
  1392. ;
  1393.  
  1394. /*
  1395.  *  item: thing
  1396.  *
  1397.  *  A basic item which can be picked up by the player.  It has no weight
  1398.  *  (0) and minimal bulk (1).  The weight property should be set
  1399.  *  to a non-zero value for heavy objects.  The bulk property
  1400.  *  should be set to a value greater than 1 for bulky objects, and to
  1401.  *  zero for objects that are very small and take essentially no effort
  1402.  *  to hold---or, more precisely, don't detract at all from the player's
  1403.  *  ability to hold other objects (for example, a piece of paper).
  1404.  */
  1405. class item: thing
  1406.     weight = 0
  1407.     bulk = 1
  1408. ;
  1409.     
  1410. /*
  1411.  *  lightsource: item
  1412.  *
  1413.  *  A portable lamp, candle, match, or other source of light.  The
  1414.  *  light source can be turned on and off with the islit property.
  1415.  *  If islit is true, the object provides light, otherwise it's
  1416.  *  just an ordinary object.  Note that this object provides a doTurnon
  1417.  *  method to provide appropriate behavior for a switchable light source,
  1418.  *  such as a flashlight or a room's electric lights.  However, this object
  1419.  *  does not provide a verDoTurnon method, so by default it can't be
  1420.  *  switched on and off.  To create something like a flashlight that should
  1421.  *  be a lightsource that can be switched on and off, simply include both
  1422.  *  lightsource and switchItem in the superclass list, and be sure
  1423.  *  that lightsource precedes switchItem in the superclass list,
  1424.  *  because the doTurnon method provided by lightsource should
  1425.  *  override the one provided by switchItem.  The doTurnon method
  1426.  *  provided here turns on the light source (by setting its isActive
  1427.  *  property to true, and then describes the room if it was previously
  1428.  *  dark.
  1429.  */
  1430. class lightsource: item
  1431.     islamp = true
  1432.     doTurnon(actor) =
  1433.     {
  1434.     local waslit := actor.location.islit;
  1435.  
  1436.     // turn on the light
  1437.     self.isActive := true;
  1438.     "You switch on <<thedesc>>";
  1439.  
  1440.     // if the room wasn't previously lit, and it is now, describe it
  1441.     if (actor.location.islit and not waslit)
  1442.     {
  1443.         ", lighting the area.\b";
  1444.         actor.location.enterRoom(actor);
  1445.     }
  1446.     else
  1447.         ".";
  1448.     }
  1449. ;
  1450.  
  1451. /*
  1452.  *  hiddenItem: object
  1453.  *
  1454.  *  This is an object that is hidden with one of the hider classes. 
  1455.  *  A hiddenItem object doesn't have any special properties in its
  1456.  *  own right, but all objects hidden with one of the hider classes
  1457.  *  must be of class hiddenItem so that initSearch can find
  1458.  *  them.
  1459.  */
  1460. class hiddenItem: object
  1461. ;
  1462.  
  1463. /*
  1464.  *  hider: item
  1465.  *
  1466.  *  This is a basic class of object that can hide other objects in various
  1467.  *  ways.  The underHider, behindHider, and searchHider classes
  1468.  *  are examples of hider subclasses.  The class defines
  1469.  *  the method searchObj(actor, list), which is given the list
  1470.  *  of hidden items contained in the object (for example, this would be the
  1471.  *  underCont property, in the case of an underHider), and "finds"
  1472.  *  the object or objects. Its action is dependent upon a couple of other
  1473.  *  properties of the hider object.  The serialSearch property,
  1474.  *  if true, indicates that items in the list are to be found one at
  1475.  *  a time; if nil (the default), the entire list is found on the
  1476.  *  first try.  The autoTake property, if true, indicates that
  1477.  *  the actor automatically takes the item or items found; if nil, the
  1478.  *  item or items are moved to the actor's location.  The searchObj method
  1479.  *  returns the list with the found object or objects removed; the
  1480.  *  caller should assign this returned value back to the appropriate
  1481.  *  property (for example, underHider will assign the return value
  1482.  *  to underCont).
  1483.  *  
  1484.  *  Note that because the hider is hiding something, this class
  1485.  *  overrides the normal verDoSearch method to display the
  1486.  *  message, "You'll have to be more specific about how you want
  1487.  *  to search that."  The reason is that the normal verDoSearch
  1488.  *  message ("You find nothing of interest") leads players to believe
  1489.  *  that the object was exhaustively searched, and we want to avoid
  1490.  *  misleading the player.  On the other hand, we don't want a general
  1491.  *  search to be exhaustive for most hider objects.  So, we just
  1492.  *  display a message letting the player know that the search was not
  1493.  *  enough, but we don't give away what they have to do instead.
  1494.  *  
  1495.  *  The objects hidden with one of the hider classes must be
  1496.  *  of class hiddenItem.
  1497.  */
  1498. class hider: item
  1499.     verDoSearch(actor) =
  1500.     {
  1501.     "%You%'ll have to be more specific about how %you% want%s%
  1502.     to search that. ";
  1503.     }
  1504.     searchObj(actor, list) =
  1505.     {
  1506.     local found, dest, i, tot;
  1507.  
  1508.     /* see how much we get this time */
  1509.     if (self.serialSearch)
  1510.     {
  1511.         found := [] + car(list);
  1512.         list := cdr(list);
  1513.     }
  1514.     else
  1515.     {
  1516.         found := list;
  1517.         list := nil;
  1518.     }
  1519.  
  1520.     /* set it(them) to the found item(s) */
  1521.         if (length(found) = 1)
  1522.         setit(found[1]);    // only one item - set 'it'
  1523.     else
  1524.         setit(found);       // multiple items - set 'them'
  1525.  
  1526.     /* figure destination */
  1527.     dest := actor;
  1528.     if (not self.autoTake) dest := dest.location;
  1529.     
  1530.     /* note what we found, and move it to destination */
  1531.     "%You% find%s% ";
  1532.     tot := length(found);
  1533.     i := 1;
  1534.     while (i <= tot)
  1535.     {
  1536.         found[i].adesc;
  1537.         if (i+1 < tot) ", ";
  1538.         else if (i = 1 and tot = 2) " and ";
  1539.         else if (i+1 = tot and tot > 2) ", and ";
  1540.         
  1541.         found[i].moveInto(dest);
  1542.         i := i + 1;
  1543.     }
  1544.  
  1545.     /* say what happened */
  1546.     if (self.autoTake) ", which %you% take%s%. ";
  1547.     else "! ";
  1548.  
  1549.     if (list<>nil and length(list)=0) list := nil;
  1550.     return(list);
  1551.     }
  1552.     serialSearch = nil             /* find everything in one try by default */
  1553.     autoTake = true               /* actor takes item when found by default */
  1554. ;
  1555.  
  1556. /*
  1557.  *  underHider: hider
  1558.  *
  1559.  *  This is an object that can have other objects placed under it.  The
  1560.  *  objects placed under it can only be found by looking under the object;
  1561.  *  see the description of hider for more information.  You should
  1562.  *  set the underLoc property of each hidden object to point to
  1563.  *  the underHider.
  1564.  *  
  1565.  *  Note that an underHider doesn't allow the player to put anything
  1566.  *  under the object during the game.  Instead, it's to make it easy for the
  1567.  *  game writer to set up hidden objects while implementing the game.  All you
  1568.  *  need to do to place an object under another object is declare the top
  1569.  *  object as an underHider, then declare the hidden object normally,
  1570.  *  except use underLoc rather than location to specify the
  1571.  *  location of the hidden object.  The behindHider and searchHider
  1572.  *  objects work similarly.
  1573.  *  
  1574.  *  The objects hidden with underHider must be of class hiddenItem.
  1575.  */
  1576. class underHider: hider
  1577.     underCont = []         /* list of items under me (set up by initSearch) */
  1578.     verDoLookunder(actor) = {}
  1579.     doLookunder(actor) =
  1580.     {
  1581.     if (self.underCont = nil)
  1582.         "There's nothing else under <<self.thedesc>>. ";
  1583.     else
  1584.         self.underCont := self.searchObj(actor, self.underCont);
  1585.     }
  1586. ;
  1587.  
  1588. /*
  1589.  *  behindHider: hider
  1590.  *
  1591.  *  This is just like an underHider, except that objects are hidden
  1592.  *  behind this object.  Objects to be behind this object should have their
  1593.  *  behindLoc property set to point to this object.
  1594.  *  
  1595.  *  The objects hidden with behindHider must be of class hiddenItem.
  1596.  */
  1597. class behindHider: hider
  1598.     behindCont = []
  1599.     verDoLookbehind(actor) = {}
  1600.     doLookbehind(actor) =
  1601.     {
  1602.     if (self.behindCont = nil)
  1603.         "There's nothing else behind <<self.thedesc>>. ";
  1604.     else
  1605.         self.behindCont := self.searchObj(actor, self.behindCont);
  1606.     }
  1607. ;
  1608.     
  1609. /*
  1610.  *  searchHider: hider
  1611.  *
  1612.  *  This is just like an underHider, except that objects are hidden
  1613.  *  within this object in such a way that the object must be looked in
  1614.  *  or searched.  Objects to be hidden in this object should have their
  1615.  *  searchLoc property set to point to this object.  Note that this
  1616.  *  is different from a normal container, in that the objects hidden within
  1617.  *  this object will not show up until the object is explicitly looked in
  1618.  *  or searched.
  1619.  *  
  1620.  *  The items hidden with searchHider must be of class hiddenItem.
  1621.  */
  1622. class searchHider: hider
  1623.     searchCont = []
  1624.     verDoSearch(actor) = {}
  1625.     doSearch(actor) =
  1626.     {
  1627.     if (self.searchCont = nil)
  1628.         "There's nothing else in <<self.thedesc>>. ";
  1629.     else
  1630.         self.searchCont := self.searchObj(actor, self.searchCont);
  1631.     }
  1632.     verDoLookin(actor) =
  1633.     {
  1634.     if (self.searchCont = nil)
  1635.         pass verDoLookin;
  1636.     }
  1637.     doLookin(actor) =
  1638.     {
  1639.     if (self.searchCont = nil)
  1640.         pass doLookin;
  1641.     else
  1642.         self.searchCont := self.searchObj(actor, self.searchCont);
  1643.     }
  1644. ;
  1645.     
  1646.  
  1647. /*
  1648.  *  fixeditem: thing
  1649.  *
  1650.  *  An object that cannot be taken or otherwise moved from its location.
  1651.  *  Note that a fixeditem is sometimes part of a movable object;
  1652.  *  this can be done to make one object part of another, ensuring that
  1653.  *  they cannot be separated.  By default, the functions that list a room's
  1654.  *  contents do not automatically describe fixeditem objects (because
  1655.  *  the isListed property is set to nil).  Instead, the game author
  1656.  *  will generally describe the fixeditem objects separately as part of
  1657.  *  the room's ldesc.  
  1658.  */
  1659. class fixeditem: thing      // An immovable object
  1660.     isListed = nil          // not listed in room/inventory displays
  1661.     isfixed = true          // Item can't be taken
  1662.     weight = 0              // no actual weight
  1663.     bulk = 0
  1664.     verDoTake( actor ) =
  1665.     {
  1666.         "%You% can't have "; self.thedesc; ". ";
  1667.     }
  1668.     verDoTakeOut( actor, io ) =
  1669.     {
  1670.         self.verDoTake( actor );
  1671.     }
  1672.     verDoDrop( actor ) =
  1673.     {
  1674.         "%You% can't drop "; self.thedesc; ". ";
  1675.     }
  1676.     verDoTakeOff( actor, io ) =
  1677.     {
  1678.         self.verDoTake( actor );
  1679.     }
  1680.     verDoPutIn( actor, io ) =
  1681.     {
  1682.         "%You% can't put "; self.thedesc; " anywhere. ";
  1683.     }
  1684.     verDoPutOn( actor, io ) =
  1685.     {
  1686.         "%You% can't put "; self.thedesc; " anywhere. ";
  1687.     }
  1688.     verDoMove( actor ) =
  1689.     {
  1690.         "%You% can't move "; self.thedesc; ". ";
  1691.     }
  1692.     verDoThrowAt(actor, iobj) =
  1693.     {
  1694.         "%You% can't throw <<self.thedesc>>.";
  1695.     }
  1696. ;
  1697.  
  1698. /*
  1699.  *  readable: item
  1700.  *
  1701.  *  An item that can be read.  The readdesc property is displayed
  1702.  *  when the item is read.  By default, the readdesc is the same
  1703.  *  as the ldesc, but the readdesc can be overridden to give
  1704.  *  a different message.
  1705.  */
  1706. class readable: item
  1707.     verDoRead( actor ) =
  1708.     {
  1709.     }
  1710.     doRead( actor ) =
  1711.     {
  1712.         self.readdesc;
  1713.     }
  1714.     readdesc =
  1715.     {
  1716.         self.ldesc;
  1717.     }
  1718. ;
  1719.  
  1720. /*
  1721.  *  fooditem: item
  1722.  *
  1723.  *  An object that can be eaten.  When eaten, the object is removed from
  1724.  *  the game, and global.lastMealTime is decremented by the
  1725.  *  foodvalue property.  By default, the foodvalue property
  1726.  *  is global.eatTime, which is the time between meals.  So, the
  1727.  *  default fooditem will last for one "nourishment interval."
  1728.  */
  1729. class fooditem: item
  1730.     verDoEat( actor ) =
  1731.     {
  1732.         self.verifyRemove( actor );
  1733.     }
  1734.     doEat( actor ) =
  1735.     {
  1736.         "That was delicious! ";
  1737.         global.lastMealTime := global.lastMealTime - self.foodvalue;
  1738.         self.moveInto( nil );
  1739.     }
  1740.     foodvalue = { return( global.eatTime ); }
  1741. ;
  1742.  
  1743. /*
  1744.  *  dialItem: fixeditem
  1745.  *
  1746.  *  This class is used for making "dials," which are controls in
  1747.  *  your game that can be turned to a range of numbers.  You must
  1748.  *  define the property maxsetting as a number specifying the
  1749.  *  highest number to which the dial can be turned; the lowest number
  1750.  *  on the dial is always 1.  The setting property is the dial's
  1751.  *  current setting, and can be changed by the player by typing the
  1752.  *  command "turn dial to number."  By default, the ldesc
  1753.  *  method displays the current setting.
  1754.  */
  1755. class dialItem: fixeditem
  1756.     maxsetting = 10 // it has settings from 1 to this number
  1757.     setting = 1     // the current setting
  1758.     ldesc =
  1759.     {
  1760.         caps(); self.thedesc; " can be turned to settings
  1761.         numbered from 1 to << self.maxsetting >>. It's
  1762.         currently set to << self.setting >>. ";
  1763.     }
  1764.     verDoTurn( actor ) = {}
  1765.     doTurn( actor ) =
  1766.     {
  1767.         askio( toPrep );
  1768.     }
  1769.     verDoTurnTo( actor, io ) = {}
  1770.     doTurnTo( actor, io ) =
  1771.     {
  1772.         if ( io = numObj )
  1773.         {
  1774.             if ( numObj.value < 1 or numObj.value > self.maxsetting )
  1775.             {
  1776.                 "There's no such setting! ";
  1777.             }
  1778.             else if ( numObj.value <> self.setting )
  1779.             {
  1780.                 self.setting := numObj.value;
  1781.                 "Okay, it's now turned to "; say( self.setting ); ". ";
  1782.             }
  1783.             else
  1784.             {
  1785.                 "It's already set to "; say( self.setting ); "! ";
  1786.             }
  1787.         }
  1788.         else
  1789.         {
  1790.             "I don't know how to turn "; self.thedesc;
  1791.             " to that. ";
  1792.         }
  1793.     }
  1794. ;
  1795.  
  1796. /*
  1797.  *  switchItem: fixeditem
  1798.  *
  1799.  *  This is a class for things that can be turned on and off by the
  1800.  *  player.  The only special property is isActive, which is nil
  1801.  *  if the switch is turned off and true when turned on.  The object
  1802.  *  accepts the commands "turn it on" and "turn it off,'' as well as
  1803.  *  synonymous constructions, and updates isActive accordingly.
  1804.  */
  1805. class switchItem: fixeditem
  1806.     verDoSwitch( actor ) = {}
  1807.     doSwitch( actor ) =
  1808.     {
  1809.         self.isActive := not self.isActive;
  1810.         "Okay, "; self.thedesc; " is now switched ";
  1811.         if ( self.isActive ) "on"; else "off";
  1812.         ". ";
  1813.     }
  1814.     verDoTurnon( actor ) =
  1815.     {
  1816.         /*
  1817.            You can't turn on something in the dark unless you're carrying
  1818.            it.  You also can't turn something on if it's already on.
  1819.         */
  1820.     if (not actor.location.islit and not actor.isCarrying(self))
  1821.         "It's pitch black.";
  1822.         else if ( self.isActive )
  1823.             "It's already turned on! ";
  1824.     }
  1825.     doTurnon( actor ) =
  1826.     {
  1827.         self.isActive := true;
  1828.         "Okay, it's now turned on. ";
  1829.     }
  1830.     verDoTurnoff( actor ) =
  1831.     {
  1832.         if ( not self.isActive ) "It's already turned off! ";
  1833.     }
  1834.     doTurnoff( actor ) =
  1835.     {
  1836.         self.isActive := nil;
  1837.         "Okay, it's now turned off. ";
  1838.     }
  1839. ;
  1840.  
  1841. /*
  1842.  *  room: thing
  1843.  *
  1844.  *  A location in the game.  By default, the islit property is
  1845.  *  true, which means that the room is lit (no light source is
  1846.  *  needed while in the room).  You should create a darkroom
  1847.  *  object rather than a room with islit set to nil if you
  1848.  *  want a dark room, because other methods are affected as well.
  1849.  *  The isseen property records whether the player has entered
  1850.  *  the room before; initially it's nil, and is set to true
  1851.  *  the first time the player enters.  The roomAction(actor,
  1852.  *  verb, directObject, preposition, indirectObject) method is
  1853.  *  activated for each player command; by default, all it does is
  1854.  *  call the room's location's roomAction method if the room
  1855.  *  is inside another room.  The lookAround(verbosity)
  1856.  *  method displays the room's description for a given verbosity
  1857.  *  level; true means a full description, nil means only
  1858.  *  the short description (just the room name plus a list of the
  1859.  *  objects present).  roomDrop(object) is called when
  1860.  *  an object is dropped within the room; normally, it just moves
  1861.  *  the object to the room and displays "Dropped."  The firstseen
  1862.  *  method is called when isseen is about to be set true
  1863.  *  for the first time (i.e., when the player first sees the room);
  1864.  *  by default, this routine does nothing, but it's a convenient
  1865.  *  place to put any special code you want to execute when a room
  1866.  *  is first entered.  The firstseen method is called after
  1867.  *  the room's description is displayed.
  1868.  */
  1869. class room: thing
  1870.     /*
  1871.      *   'reachable' is the list of explicitly reachable objects, over and
  1872.      *   above the objects that are here.  This is mostly used in nested
  1873.      *   rooms to make objects in the containing room accessible.  Most
  1874.      *   normal rooms will leave this as an empty list.
  1875.      */
  1876.     reachable = []
  1877.     
  1878.     /*
  1879.      *   roomCheck is true if the verb is valid in the room.  This
  1880.      *   is a first pass; generally, its only function is to disallow
  1881.      *   certain commands in a dark room.
  1882.      */
  1883.     roomCheck( v ) = { return( true ); }
  1884.     islit = true            // rooms are lit unless otherwise specified
  1885.     isseen = nil            // room has not been seen yet
  1886.     enterRoom( actor ) =    // sent to room as actor is entering it
  1887.     {
  1888.         self.lookAround(( not self.isseen ) or global.verbose );
  1889.         if ( self.islit )
  1890.     {
  1891.         if (not self.isseen) self.firstseen;
  1892.         self.isseen := true;
  1893.     }
  1894.     }
  1895.     roomAction( a, v, d, p, i ) =
  1896.     {
  1897.         if ( self.location ) self.location.roomAction( a, v, d, p, i );
  1898.     }
  1899.  
  1900.     /*
  1901.      *   Whenever a normal object (i.e., one that does not override the
  1902.      *   default doDrop provided by 'thing') is dropped, the actor's
  1903.      *   location is sent roomDrop(object being dropped).  By default, 
  1904.      *   we move the object into this room.
  1905.      */
  1906.     roomDrop( obj ) =
  1907.     {
  1908.         "Dropped. ";
  1909.     obj.moveInto( self );
  1910.     }
  1911.  
  1912.     /*
  1913.      *   Whenever an actor leaves this room, we run through the leaveList.
  1914.      *   This is a list of objects that have registered themselves with us
  1915.      *   via addLeaveList().  For each object in the leaveList, we send
  1916.      *   a "leaving" message, with the actor as the parameter.  It should
  1917.      *   return true if it wants to be removed from the leaveList, nil
  1918.      *   if it wants to stay.
  1919.      */
  1920.     leaveList = []
  1921.     addLeaveList( obj ) =
  1922.     {
  1923.         self.leaveList := self.leaveList + obj;
  1924.     }
  1925.     leaveRoom( actor ) =
  1926.     {
  1927.         local tmplist, thisobj, i, tot;
  1928.  
  1929.         tmplist := self.leaveList;
  1930.     tot := length( tmplist );
  1931.     i := 1;
  1932.         while ( i <= tot )
  1933.         {
  1934.         thisobj := tmplist[i];
  1935.             if ( thisobj.leaving( actor ))
  1936.                 self.leaveList := self.leaveList - thisobj;
  1937.             i := i + 1;
  1938.         }
  1939.     }
  1940.     /*
  1941.      *   lookAround describes the room.  If verbosity is true, the full
  1942.      *   description is given, otherwise an abbreviated description (without
  1943.      *   the room's ldesc) is displayed.
  1944.      */
  1945.     nrmLkAround( verbosity ) =      // lookAround without location status
  1946.     {
  1947.         local l, cur, i, tot;
  1948.  
  1949.         if ( verbosity )
  1950.         {
  1951.             "\n\t"; self.ldesc;
  1952.  
  1953.             l := self.contents;
  1954.         tot := length( l );
  1955.         i := 1;
  1956.             while ( i <= tot )
  1957.             {
  1958.             cur := l[i];
  1959.                 if ( cur.isfixed ) cur.heredesc;
  1960.                 i := i + 1;
  1961.             }
  1962.         }
  1963.         "\n\t";
  1964.         if (itemcnt( self.contents ))
  1965.         {
  1966.             "You see "; listcont( self ); " here. ";
  1967.         }
  1968.         listcontcont( self ); "\n";
  1969.  
  1970.         l := self.contents;
  1971.     tot := length( l );
  1972.     i := 1;
  1973.         while ( i <= tot )
  1974.         {
  1975.         cur := l[i];
  1976.             if ( cur.isactor )
  1977.             {
  1978.                 if ( cur <> Me )
  1979.                 {
  1980.                     "\n\t";
  1981.                     cur.actorDesc;
  1982.                 }
  1983.             }
  1984.             i := i + 1;
  1985.         }
  1986.     }
  1987.     statusLine =
  1988.     {
  1989.         self.sdesc; "\n\t";
  1990.     }
  1991.     lookAround( verbosity ) =
  1992.     {
  1993.         self.statusLine;
  1994.         self.nrmLkAround( verbosity );
  1995.     }
  1996.     
  1997.     /*
  1998.      *   Direction handlers.  The directions are all set up to
  1999.      *   the default, which is no travel allowed.  To make travel
  2000.      *   possible in a direction, just assign a room to the direction
  2001.      *   property.
  2002.      */
  2003.     north = { return( self.noexit ); }
  2004.     south = { return( self.noexit ); }
  2005.     east  = { return( self.noexit ); }
  2006.     west  = { return( self.noexit ); }
  2007.     up    = { return( self.noexit ); }
  2008.     down  = { return( self.noexit ); }
  2009.     ne    = { return( self.noexit ); }
  2010.     nw    = { return( self.noexit ); }
  2011.     se    = { return( self.noexit ); }
  2012.     sw    = { return( self.noexit ); }
  2013.     in    = { return( self.noexit ); }
  2014.     out   = { return( self.noexit ); }
  2015.     
  2016.     /*
  2017.      *   noexit displays a message when the player attempts to travel
  2018.      *   in a direction in which travel is not possible.
  2019.      */
  2020.     noexit = { "%You% can't go that way. "; return( nil ); }
  2021. ;
  2022.  
  2023. /*
  2024.  *  darkroom: room
  2025.  *
  2026.  *  A dark room.  The player must have some object that can act as a
  2027.  *  light source in order to move about and perform most operations
  2028.  *  while in this room.  Note that the room's lights can be turned
  2029.  *  on by setting the room's lightsOn property to true;
  2030.  *  do this instead of setting islit, because islit is
  2031.  *  a method which checks for the presence of a light source.
  2032.  */
  2033. class darkroom: room        // An enterable area which might be dark
  2034.     islit =                 // true ONLY if something is lighting the room
  2035.     {
  2036.         local rem, cur, tot, i;
  2037.  
  2038.     if ( self.lightsOn ) return( true );
  2039.  
  2040.     rem := global.lamplist;
  2041.     tot := length( rem );
  2042.     i := 1;
  2043.     while ( i <= tot )
  2044.     {
  2045.         cur := rem[i];
  2046.         if ( cur.isIn( self ) and cur.islit ) return( true );
  2047.         i := i + 1;
  2048.     }
  2049.     return( nil );
  2050.     }
  2051.     roomAction( actor, v, dobj, prep, io ) =
  2052.     {
  2053.         if ( not self.islit and not v.isDarkVerb )
  2054.     {
  2055.         "%You% can't see a thing. ";
  2056.         exit;
  2057.     }
  2058.     else pass roomAction;
  2059.     }
  2060.     statusLine =
  2061.     {
  2062.         if ( self.islit ) pass statusLine;
  2063.     else "In the dark.";
  2064.     }
  2065.     lookAround( verbosity ) =
  2066.     {
  2067.         if ( self.islit ) pass lookAround;
  2068.     else "It's pitch black. ";
  2069.     }
  2070.     noexit =
  2071.     {
  2072.         if ( self.islit ) pass noexit;
  2073.     else
  2074.     {
  2075.         darkTravel();
  2076.         return( nil );
  2077.     }
  2078.     }
  2079.     roomCheck( v ) =
  2080.     {
  2081.         if ( self.islit or v.isDarkVerb ) return( true );
  2082.     else
  2083.     {
  2084.         "It's pitch black.\n";
  2085.         return( nil );
  2086.     }
  2087.     }
  2088. ;
  2089.  
  2090. /*
  2091.  *  theFloor is a special item that appears in every room (hence
  2092.  *  the non-standard location property).  This object is included
  2093.  *  mostly for completeness, so that the player can refer to the
  2094.  *  floor; otherwise, it doesn't do much.  Dropping an item on the
  2095.  *  floor, for example, moves it to the current room.
  2096.  */
  2097. theFloor: beditem, floatingItem
  2098.     noun = 'floor' 'ground'
  2099.     sdesc = "ground"
  2100.     adesc = "the ground"
  2101.     statusPrep = "on"
  2102.     outOfPrep = "off of"
  2103.     location =
  2104.     {
  2105.         if ( Me.location = self )
  2106.             return( self.sitloc );
  2107.         else
  2108.             return( Me.location );
  2109.     }
  2110.     locationOK = true        // suppress warning about location being a method
  2111.     doSiton( actor ) =
  2112.     {
  2113.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  2114.         self.sitloc := actor.location;
  2115.         actor.moveInto( self );
  2116.     }
  2117.     doLieon( actor ) =
  2118.     {
  2119.         self.doSiton( actor );
  2120.     }
  2121.     ioPutOn( actor, dobj ) =
  2122.     {
  2123.         dobj.doDrop( actor );
  2124.     }
  2125.     ioPutIn( actor, dobj ) =
  2126.     {
  2127.         dobj.doDrop( actor );
  2128.     }
  2129. ;
  2130.  
  2131. /*
  2132.  *  Actor: fixeditem, movableActor
  2133.  *
  2134.  *  A character in the game.  The maxweight property specifies
  2135.  *  the maximum weight that the character can carry, and the maxbulk
  2136.  *  property specifies the maximum bulk the character can carry.  The
  2137.  *  actorAction(verb, directObject, preposition, indirectObject)
  2138.  *  method specifies what happens when the actor is given a command by
  2139.  *  the player; by default, the actor ignores the command and displays
  2140.  *  a message to this effect.  The isCarrying(object)
  2141.  *  method returns true if the object is being carried by
  2142.  *  the actor.  The actorDesc method displays a message when the
  2143.  *  actor is in the current room; this message is displayed along with
  2144.  *  a room's description when the room is entered or examined.  The
  2145.  *  verGrab(object) method is called when someone tries to
  2146.  *  take an object the actor is carrying; by default, an actor won't
  2147.  *  let other characters take its possessions.
  2148.  *  
  2149.  *  If you want the player to be able to follow the actor when it
  2150.  *  leaves the room, you should define a follower object to shadow
  2151.  *  the character, and set the actor's myfollower property to
  2152.  *  the follower object.  The follower is then automatically
  2153.  *  moved around just behind the actor by the actor's moveInto
  2154.  *  method.
  2155.  *  
  2156.  *  The isHim property should return true if the actor can
  2157.  *  be referred to by the player as "him," and likewise isHer
  2158.  *  should be set to true if the actor can be referred to as "her."
  2159.  *  Note that both or neither can be set; if neither is set, the actor
  2160.  *  can only be referred to as "it," and if both are set, any of "him,''
  2161.  *  "her," or "it'' will be accepted.
  2162.  */
  2163. class Actor: fixeditem, movableActor
  2164. ;
  2165.  
  2166. /*
  2167.  *  movableActor: qcontainer
  2168.  *
  2169.  *  Just like an Actor object, except that the player can
  2170.  *  manipulate the actor like an ordinary item.  Useful for certain
  2171.  *  types of actors, such as small animals.
  2172.  */
  2173. class movableActor: qcontainer // A character in the game
  2174.     isListed = nil          // described separately from room's contents
  2175.     weight = 10             // actors are pretty heavy
  2176.     bulk = 10               // and pretty bulky
  2177.     maxweight = 50          // Weight that can be carried at once
  2178.     maxbulk = 20            // Number of objects that can be carried at once
  2179.     isactor = true          // flag that this is an actor
  2180.     roomCheck( v ) = { return( self.location.roomCheck(v)); }
  2181.     actorAction( v, d, p, i ) =
  2182.     {
  2183.         caps(); self.thedesc; " doesn't appear interested. ";
  2184.         exit;
  2185.     }
  2186.     isCarrying( obj ) = { return( obj.isIn( self )); }
  2187.     actorDesc =
  2188.     {
  2189.         caps(); self.adesc; " is here. ";
  2190.     }
  2191.     verGrab( item ) =
  2192.     {
  2193.         caps(); self.thedesc; " is carrying "; item.thedesc;
  2194.         " and won't let %youm% have it. ";
  2195.     }
  2196.     verDoFollow( actor ) =
  2197.     {
  2198.         "But "; self.thedesc; " is right here! ";
  2199.     }
  2200.     moveInto( obj ) =
  2201.     {
  2202.         if ( self.myfollower ) self.myfollower.moveInto( self.location );
  2203.     pass moveInto;
  2204.     }
  2205.     // these properties are for the format strings
  2206.     fmtYou = "he"
  2207.     fmtYour = "his"
  2208.     fmtYoure = "he's"
  2209.     fmtYoum = "him"
  2210.     fmtYouve = "he's"
  2211.     fmtS = "s"
  2212.     fmtEs = "es"
  2213.     fmtHave = "has"
  2214.     fmtDo = "does"
  2215.     fmtAre = "is"
  2216.     fmtMe = { self.thedesc; }
  2217.     askWord(word, lst) = { return(nil); }
  2218.     verDoAskAbout(actor, iobj) = {}
  2219.     doAskAbout(actor, iobj) =
  2220.     {
  2221.     local lst, i, tot;
  2222.  
  2223.     lst := objwords(2);       // get actual words asked about
  2224.     tot := length(lst);
  2225.     if ((tot = 1 and (find(['it' 'them' 'him' 'her'], lst[1]) <> nil))
  2226.         or tot = 0)
  2227.     {
  2228.         "\"Could you be more specific?\"";
  2229.         return;
  2230.     }
  2231.  
  2232.     // try to find a response for each word
  2233.     for (i := 1 ; i <= tot ; ++i)
  2234.     {
  2235.         if (self.askWord(lst[i], lst))
  2236.             return;
  2237.         }
  2238.  
  2239.     // didn't find anything to talk about
  2240.     self.disavow;
  2241.     }
  2242.     disavow = "\"I don't know much about that.\""
  2243.     verIoPutIn(actor) =
  2244.     {
  2245.         "If you want to give that to << thedesc >>, just say so.";
  2246.     }
  2247.     verIoGiveTo(actor) =
  2248.     {
  2249.     if (actor = self)
  2250.         "That wouldn't accomplish anything!";
  2251.     }
  2252.     ioGiveTo(actor, dobj) =
  2253.     {
  2254.     "\^<<self.thedesc>> rejects the offer.";
  2255.     }
  2256.  
  2257.     // move to a new location, notifying player of coming and going
  2258.     travelTo(room) =
  2259.     {
  2260.     /* do nothing if going nowhere */
  2261.     if (room = nil) return;
  2262.     
  2263.         /* notify player if leaving player's location (and it's not dark) */
  2264.         if (self.location = Me.location and self.location.islit)
  2265.             self.sayLeaving;
  2266.  
  2267.         /* move to my new location */
  2268.         self.moveInto(room);
  2269.  
  2270.         /* notify player if arriving at player's location */
  2271.         if (self.location = Me.location and self.location.islit)
  2272.             self.sayArriving;
  2273.     }
  2274.  
  2275.     // sayLeaving and sayArriving announce the actor's departure and arrival
  2276.     // in the same room as the player.
  2277.     sayLeaving = "\n\t\^<<self.thedesc>> leaves the area."
  2278.     sayArriving = "\n\t\^<<self.thedesc>> enters the area."
  2279.  
  2280.     // this should be used as an actor when ambiguous
  2281.     preferredActor = true
  2282. ;
  2283.  
  2284. /*
  2285.  *  follower: Actor
  2286.  *
  2287.  *  This is a special object that can "shadow" the movements of a
  2288.  *  character as it moves from room to room.  The purpose of a follower
  2289.  *  is to allow the player to follow an actor as it leaves a room by
  2290.  *  typing a "follow" command.  Each actor that is to be followed must
  2291.  *  have its own follower object.  The follower object should
  2292.  *  define all of the same vocabulary words (nouns and adjectives) as the
  2293.  *  actual actor to which it refers.  The follower must also
  2294.  *  define the myactor property to be the Actor object that
  2295.  *  the follower follows.  The follower will always stay
  2296.  *  one room behind the character it follows; no commands are effective
  2297.  *  with a follower except for "follow."
  2298.  */
  2299. class follower: Actor
  2300.     sdesc = { self.myactor.sdesc; }
  2301.     isfollower = true
  2302.     ldesc = { caps(); self.thedesc; " is no longer here. "; }
  2303.     actorAction( v, d, p, i ) = { self.ldesc; exit; }
  2304.     actorDesc = {}
  2305.     myactor = nil   // set to the Actor to be followed
  2306.     verDoFollow( actor ) = {}
  2307.     doFollow( actor ) =
  2308.     {
  2309.         actor.travelTo( self.myactor.location );
  2310.     }
  2311.     dobjGen(a, v, i, p) =
  2312.     {
  2313.         if (v <> followVerb)
  2314.     {
  2315.         "\^<< self.myactor.thedesc >> is no longer here.";
  2316.         exit;
  2317.     }
  2318.     }
  2319.     iobjGen(a, v, d, p) =
  2320.     {
  2321.         "\^<< self.myactor.thedesc >> is no longer here.";
  2322.     exit;
  2323.     }
  2324. ;
  2325.  
  2326. /*
  2327.  *  basicMe: Actor
  2328.  *
  2329.  *  A default implementation of the Me object, which is the
  2330.  *  player character.  adv.t defines basicMe instead of
  2331.  *  Me to allow your game to override parts of the default
  2332.  *  implementation while still using the rest, and without changing
  2333.  *  adv.t itself.  To use basicMe unchanged as your player
  2334.  *  character, include this in your game:  "Me: basicMe;".
  2335.  *  
  2336.  *  The basicMe object defines all of the methods and properties
  2337.  *  required for an actor, with appropriate values for the player
  2338.  *  character.  The nouns "me" and "myself'' are defined ("I''
  2339.  *  is not defined, because it conflicts with the "inventory"
  2340.  *  command's minimal abbreviation of "i" in certain circumstances,
  2341.  *  and is generally not compatible with the syntax of most player
  2342.  *  commands anyway).  The sdesc is "you"; the thedesc
  2343.  *  and adesc are "yourself," which is appropriate for most
  2344.  *  contexts.  The maxbulk and maxweight properties are
  2345.  *  set to 10 each; a more sophisticated Me might include the
  2346.  *  player's state of health in determining the maxweight and
  2347.  *  maxbulk properties.
  2348.  */
  2349. class basicMe: Actor, floatingItem
  2350.     roomCheck( v ) = { return( self.location.roomCheck( v )); }
  2351.     noun = 'me' 'myself'
  2352.     sdesc = "you"
  2353.     thedesc = "yourself"
  2354.     adesc = "yourself"
  2355.     ldesc = "You look about the same as always. "
  2356.     maxweight = 10
  2357.     maxbulk = 10
  2358.     verDoFollow( actor ) =
  2359.     {
  2360.         if ( actor = self ) "You can't follow yourself! ";
  2361.     }
  2362.     actorAction( verb, dobj, prep, iobj ) = 
  2363.     {
  2364.     }
  2365.     travelTo( room ) =
  2366.     {
  2367.         if ( room )
  2368.         {
  2369.         if ( room.isobstacle )
  2370.         {
  2371.             self.travelTo( room.destination );
  2372.         }
  2373.         else if ( not ( self.location.islit or room.islit ))
  2374.         {
  2375.             darkTravel();
  2376.         }
  2377.         else
  2378.         {
  2379.                 if ( self.location ) self.location.leaveRoom( self );
  2380.                 self.location := room;
  2381.                 room.enterRoom( self );
  2382.         }
  2383.         }
  2384.     }
  2385.     moveInto( room ) =
  2386.     {
  2387.         self.location := room;
  2388.     }
  2389.     ioGiveTo(actor, dobj) =
  2390.     {
  2391.     "You accept <<dobj.thedesc>> from <<actor.thedesc>>.";
  2392.     dobj.moveInto(Me);
  2393.     }
  2394.  
  2395.     // these properties are for the format strings
  2396.     fmtYou = "you"
  2397.     fmtYour = "your"
  2398.     fmtYoure = "you're"
  2399.     fmtYoum = "you"
  2400.     fmtYouve = "you've"
  2401.     fmtS = ""
  2402.     fmtEs = ""
  2403.     fmtHave = "have"
  2404.     fmtDo = "do"
  2405.     fmtAre = "are"
  2406.     fmtMe = "me"
  2407. ;
  2408.  
  2409. /*
  2410.  *  decoration: fixeditem
  2411.  *
  2412.  *  An item that doesn't have any function in the game, apart from
  2413.  *  having been mentioned in the room description.  These items
  2414.  *  are immovable and can't be manipulated in any way, but can be
  2415.  *  referred to and inspected.  Liberal use of decoration items
  2416.  *  can improve a game's playability by helping the parser recognize
  2417.  *  all the words the game uses in its descriptions of rooms.
  2418.  */
  2419. class decoration: fixeditem
  2420.     ldesc = "That's not important."
  2421.     dobjGen(a, v, i, p) =
  2422.     {
  2423.         if (v <> inspectVerb)
  2424.     {
  2425.         "\^<<self.thedesc>> isn't important.";
  2426.         exit;
  2427.     }
  2428.     }
  2429.     iobjGen(a, v, d, p) =
  2430.     {
  2431.         "\^<<self.thedesc>> isn't important.";
  2432.     exit;
  2433.     }
  2434. ;
  2435.  
  2436. /*
  2437.  *  distantItem: fixeditem
  2438.  *
  2439.  *  This is an item that is too far away to manipulate, but can be seen.
  2440.  *  The class uses dobjGen and iobjGen to prevent any verbs from being
  2441.  *  used on the object apart from inspectVerb; using any other verb results
  2442.  *  in the message "It's too far away."  Instances of this class should
  2443.  *  provide the normal item properties:  sdesc, ldesc, location,
  2444.  *  and vocabulary.
  2445.  */
  2446. class distantItem: fixeditem
  2447.     dobjGen(a, v, i, p) =
  2448.     {
  2449.         if (v <> inspectVerb)
  2450.         {
  2451.             "It's too far away.";
  2452.             exit;
  2453.         }
  2454.     }
  2455.     iobjGen(a, v, d, p) = { self.dobjGen(a, v, d, p); }
  2456. ;
  2457.  
  2458. /*
  2459.  *  buttonitem: fixeditem
  2460.  *
  2461.  *  A button (the type you push).  The individual button's action method
  2462.  *  doPush(actor), which must be specified in
  2463.  *  the button, carries out the function of the button.  Note that
  2464.  *  all buttons have the noun "button" defined.
  2465.  */
  2466. class buttonitem: fixeditem
  2467.     noun = 'button'
  2468.     plural = 'buttons'
  2469.     verDoPush( actor ) = {}
  2470. ;
  2471.  
  2472. /*
  2473.  *  clothingItem: item
  2474.  *
  2475.  *  Something that can be worn.  By default, the only thing that
  2476.  *  happens when the item is worn is that its isworn property
  2477.  *  is set to true.  If you want more to happen, override the
  2478.  *  doWear(actor) property.  Note that, when a clothingItem
  2479.  *  is being worn, certain operations will cause it to be removed (for
  2480.  *  example, dropping it causes it to be removed).  If you want
  2481.  *  something else to happen, override the checkDrop method;
  2482.  *  if you want to disallow such actions while the object is worn,
  2483.  *  use an exit statement in the checkDrop method.
  2484.  */
  2485. class clothingItem: item
  2486.     checkDrop =
  2487.     {
  2488.         if ( self.isworn )
  2489.     {
  2490.         "(Taking off "; self.thedesc; " first)\n";
  2491.         self.isworn := nil;
  2492.     }
  2493.     }
  2494.     doDrop( actor ) =
  2495.     {
  2496.         self.checkDrop;
  2497.     pass doDrop;
  2498.     }
  2499.     doPutIn( actor, io ) =
  2500.     {
  2501.         self.checkDrop;
  2502.     pass doPutIn;
  2503.     }
  2504.     doPutOn( actor, io ) =
  2505.     {
  2506.         self.checkDrop;
  2507.     pass doPutOn;
  2508.     }
  2509.     doGiveTo( actor, io ) =
  2510.     {
  2511.         self.checkDrop;
  2512.     pass doGiveTo;
  2513.     }
  2514.     doThrowAt( actor, io ) =
  2515.     {
  2516.         self.checkDrop;
  2517.     pass doThrowAt;
  2518.     }
  2519.     doThrowTo( actor, io ) =
  2520.     {
  2521.         self.checkDrop;
  2522.     pass doThrowTo;
  2523.     }
  2524.     doThrow( actor ) =
  2525.     {
  2526.         self.checkDrop;
  2527.     pass doThrow;
  2528.     }
  2529.     moveInto( obj ) =
  2530.     {
  2531.         /*
  2532.      *   Catch any other movements with moveInto; this won't stop the
  2533.      *   movement from happening, but it will prevent any anamolous
  2534.      *   consequences caused by the object moving but still being worn.
  2535.      */
  2536.         self.isworn := nil;
  2537.     pass moveInto;
  2538.     }
  2539.     verDoWear( actor ) =
  2540.     {
  2541.         if ( self.isworn )
  2542.         {
  2543.             "%You're% already wearing "; self.thedesc; "! ";
  2544.         }
  2545.         else if ( not actor.isCarrying( self ))
  2546.         {
  2547.             "%You% %do%n't have "; self.thedesc; ". ";
  2548.         }
  2549.     }
  2550.     doWear( actor ) =
  2551.     {
  2552.         "Okay, %you're% now wearing "; self.thedesc; ". ";
  2553.         self.isworn := true;
  2554.     }
  2555.     verDoUnwear( actor ) =
  2556.     {
  2557.         if ( not self.isworn )
  2558.         {
  2559.             "%You're% not wearing "; self.thedesc; ". ";
  2560.         }
  2561.     }
  2562.     verDoTake(actor) =
  2563.     {
  2564.         if (self.isworn) self.verDoUnwear(actor);
  2565.     else pass verDoTake;
  2566.     }
  2567.     doTake(actor) =
  2568.     {
  2569.         if (self.isworn) self.doUnwear(actor);
  2570.     else pass doTake;
  2571.     }
  2572.     doUnwear( actor ) =
  2573.     {
  2574.         "Okay, %you're% no longer wearing "; self.thedesc; ". ";
  2575.         self.isworn := nil;
  2576.     }
  2577.     doSynonym('Unwear') = 'Unboard'
  2578. ;
  2579.  
  2580. /*
  2581.  *  obstacle: object
  2582.  *
  2583.  *  An obstacle is used in place of a room for a direction
  2584.  *  property.  The destination property specifies the room that
  2585.  *  is reached if the obstacle is successfully negotiated; when the
  2586.  *  obstacle is not successfully negotiated, destination should
  2587.  *  display an appropriate message and return nil.
  2588.  */
  2589. class obstacle: object
  2590.     isobstacle = true
  2591. ;
  2592.  
  2593. /*
  2594.  *  doorway: fixeditem, obstacle
  2595.  *
  2596.  *  A doorway is an obstacle that impedes progress when it is closed.
  2597.  *  When the door is open (isopen is true), the user ends up in
  2598.  *  the room specified in the doordest property upon going through
  2599.  *  the door.  Since a doorway is an obstacle, use the door object for
  2600.  *  a direction property of the room containing the door.
  2601.  *  
  2602.  *  If noAutoOpen is not set to true, the door will automatically
  2603.  *  be opened when the player tries to walk through the door, unless the
  2604.  *  door is locked (islocked = true).  If the door is locked,
  2605.  *  it can be unlocked simply by typing "unlock door", unless the
  2606.  *  mykey property is set, in which case the object specified in
  2607.  *  mykey must be used to unlock the door.  Note that the door can
  2608.  *  only be relocked by the player under the circumstances that allow
  2609.  *  unlocking, plus the property islockable must be set to true.
  2610.  *  By default, the door is closed; set isopen to true if the door
  2611.  *  is to start out open (and be sure to open the other side as well).
  2612.  *  
  2613.  *  otherside specifies the corresponding doorway object in the
  2614.  *  destination room (doordest), if any.  If otherside is
  2615.  *  specified, its isopen and islocked properties will be
  2616.  *  kept in sync automatically.
  2617.  */
  2618. class doorway: fixeditem, obstacle
  2619.     isdoor = true           // Item can be opened and closed
  2620.     destination =
  2621.     {
  2622.         if ( self.isopen ) return( self.doordest );
  2623.     else if ( not self.islocked and not self.noAutoOpen )
  2624.     {
  2625.         self.isopen := true;
  2626.         if ( self.otherside ) self.otherside.isopen := true;
  2627.         "(Opening << self.thedesc >>)\n";
  2628.         return( self.doordest );
  2629.     }
  2630.     else
  2631.     {
  2632.         "%You%'ll have to open << self.thedesc >> first. ";
  2633.         setit( self );
  2634.         return( nil );
  2635.     }
  2636.     }
  2637.     verDoOpen( actor ) =
  2638.     {
  2639.         if ( self.isopen ) "It's already open. ";
  2640.     else if ( self.islocked ) "It's locked. ";
  2641.     }
  2642.     doOpen( actor ) =
  2643.     {
  2644.         "Opened. ";
  2645.     self.isopen := true;
  2646.     if ( self.otherside ) self.otherside.isopen := true;
  2647.     }
  2648.     verDoClose( actor ) =
  2649.     {
  2650.         if ( not self.isopen ) "It's already closed. ";
  2651.     }
  2652.     doClose( actor ) =
  2653.     {
  2654.         "Closed. ";
  2655.     self.isopen := nil;
  2656.     if ( self.otherside ) self.otherside.isopen := nil;
  2657.     }
  2658.     verDoLock( actor ) =
  2659.     {
  2660.         if ( self.islocked ) "It's already locked! ";
  2661.     else if ( not self.islockable ) "It can't be locked. ";
  2662.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2663.     }
  2664.     doLock( actor ) =
  2665.     {
  2666.         if ( self.mykey = nil )
  2667.     {
  2668.         "Locked. ";
  2669.         self.islocked := true;
  2670.         if ( self.otherside ) self.otherside.islocked := true;
  2671.     }
  2672.     else
  2673.             askio( withPrep );
  2674.     }
  2675.     verDoUnlock( actor ) =
  2676.     {
  2677.         if ( not self.islocked ) "It's not locked! ";
  2678.     }
  2679.     doUnlock( actor ) =
  2680.     {
  2681.         if ( self.mykey = nil )
  2682.     {
  2683.         "Unlocked. ";
  2684.         self.islocked := nil;
  2685.         if ( self.otherside ) self.otherside.islocked := nil;
  2686.     }
  2687.     else
  2688.         askio( withPrep );
  2689.     }
  2690.     verDoLockWith( actor, io ) =
  2691.     {
  2692.         if ( self.islocked ) "It's already locked. ";
  2693.     else if ( not self.islockable ) "It can't be locked. ";
  2694.     else if ( self.mykey = nil )
  2695.         "%You% %do%n't need anything to lock it. ";
  2696.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2697.     }
  2698.     doLockWith( actor, io ) =
  2699.     {
  2700.         if ( io = self.mykey )
  2701.     {
  2702.         "Locked. ";
  2703.         self.islocked := true;
  2704.         if ( self.otherside ) self.otherside.islocked := true;
  2705.     }
  2706.     else "It doesn't fit the lock. ";
  2707.     }
  2708.     verDoUnlockWith( actor, io ) =
  2709.     {
  2710.         if ( not self.islocked ) "It's not locked! ";
  2711.     else if ( self.mykey = nil )
  2712.         "%You% %do%n't need anything to unlock it. ";
  2713.     }
  2714.     doUnlockWith( actor, io ) =
  2715.     {
  2716.         if ( io = self.mykey )
  2717.     {
  2718.         "Unlocked. ";
  2719.         self.islocked := nil;
  2720.         if ( self.otherside ) self.otherside.islocked := nil;
  2721.     }
  2722.     else "It doesn't fit the lock. ";
  2723.     }
  2724.     ldesc =
  2725.     {
  2726.     if ( self.isopen ) "It's open. ";
  2727.     else
  2728.     {
  2729.         if ( self.islocked ) "It's closed and locked. ";
  2730.         else "It's closed. ";
  2731.     }
  2732.     }
  2733. ;
  2734.  
  2735. /*
  2736.  *  lockableDoorway: doorway
  2737.  *
  2738.  *  This is just a normal doorway with the islockable and
  2739.  *  islocked properties set to true.  Fill in the other
  2740.  *  properties (otherside and doordest) as usual.  If
  2741.  *  the door has a key, set property mykey to the key object.
  2742.  */
  2743. class lockableDoorway: doorway
  2744.     islockable = true
  2745.     islocked = true
  2746. ;
  2747.  
  2748. /*
  2749.  *  vehicle: item, nestedroom
  2750.  *
  2751.  *  This is an object that an actor can board.  An actor cannot go
  2752.  *  anywhere while on board a vehicle (except where the vehicle goes);
  2753.  *  the actor must get out first.
  2754.  */
  2755. class vehicle: item, nestedroom
  2756.     reachable = ([] + self)
  2757.     isvehicle = true
  2758.     verDoEnter( actor ) = { self.verDoBoard( actor ); }
  2759.     doEnter( actor ) = { self.doBoard( actor ); }
  2760.     verDoBoard( actor ) =
  2761.     {
  2762.         if ( actor.location = self )
  2763.         {
  2764.             "%You're% already in "; self.thedesc; "! ";
  2765.         }
  2766.     else if (actor.isCarrying(self))
  2767.     {
  2768.         "%You%'ll have to drop <<thedesc>> first!";
  2769.     }
  2770.     }
  2771.     doBoard( actor ) =
  2772.     {
  2773.         "Okay, %you're% now in "; self.thedesc; ". ";
  2774.         actor.moveInto( self );
  2775.     }
  2776.     noexit =
  2777.     {
  2778.         "%You're% not going anywhere until %you% get%s% out of ";
  2779.       self.thedesc; ". ";
  2780.         return( nil );
  2781.     }
  2782.     out = ( self.location )
  2783.     verDoTake(actor) =
  2784.     {
  2785.         if (actor.isIn(self))
  2786.         "%You%'ll have to get <<self.outOfPrep>> <<self.thedesc>> first.";
  2787.     else
  2788.         pass verDoTake;
  2789.     }
  2790.     dobjGen(a, v, i, p) =
  2791.     {
  2792.         if (a.isIn(self) and v <> inspectVerb and v <> getOutVerb
  2793.         and v <> outVerb)
  2794.     {
  2795.         "%You%'ll have to get out of << thedesc >> first.";
  2796.         exit;
  2797.     }
  2798.     }
  2799.     iobjGen(a, v, d, p) =
  2800.     {
  2801.         if (a.isIn(self) and v <> putVerb)
  2802.     {
  2803.         "%You%'ll have to get out of << thedesc >> first.";
  2804.         exit;
  2805.     }
  2806.     }
  2807. ;
  2808.  
  2809. /*
  2810.  *  surface: item
  2811.  *
  2812.  *  Objects can be placed on a surface.  Apart from using the
  2813.  *  preposition "on" rather than "in'' to refer to objects
  2814.  *  contained by the object, a surface is identical to a
  2815.  *  container.  Note: an object cannot be both a
  2816.  *  surface and a container, because there is no
  2817.  *  distinction between the two internally.
  2818.  */
  2819. class surface: item
  2820.     issurface = true        // Item can hold objects on its surface
  2821.     ldesc =
  2822.     {
  2823.         if (itemcnt( self.contents ))
  2824.         {
  2825.             "On "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2826.         }
  2827.         else
  2828.         {
  2829.             "There's nothing on "; self.thedesc; ". ";
  2830.         }
  2831.     }
  2832.     verIoPutOn( actor ) = {}
  2833.     ioPutOn( actor, dobj ) =
  2834.     {
  2835.         dobj.doPutOn( actor, self );
  2836.     }
  2837. ;
  2838.  
  2839. /*
  2840.  *  container: item
  2841.  *
  2842.  *  This object can contain other objects.  The iscontainer property
  2843.  *  is set to true.  The default ldesc displays a list of the
  2844.  *  objects inside the container, if any.  The maxbulk property
  2845.  *  specifies the maximum amount of bulk the container can contain.
  2846.  */
  2847. class container: item
  2848.     maxbulk = 10            // maximum bulk the container can contain
  2849.     isopen = true           // in fact, it can't be closed at all
  2850.     iscontainer = true      // Item can contain other items
  2851.     ldesc =
  2852.     {
  2853.         if ( self.contentsVisible and itemcnt( self.contents ) <> 0 )
  2854.         {
  2855.             "In "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2856.         }
  2857.         else
  2858.         {
  2859.             "There's nothing in "; self.thedesc; ". ";
  2860.         }
  2861.     }
  2862.     verIoPutIn( actor ) =
  2863.     {
  2864.     }
  2865.     ioPutIn( actor, dobj ) =
  2866.     {
  2867.         if (addbulk( self.contents ) + dobj.bulk > self.maxbulk )
  2868.         {
  2869.             "%You% can't fit that in "; self.thedesc; ". ";
  2870.         }
  2871.         else
  2872.         {
  2873.         dobj.doPutIn( actor, self );
  2874.         }
  2875.     }
  2876.     verDoLookin( actor ) = {}
  2877.     doLookin( actor ) =
  2878.     {
  2879.         self.ldesc;
  2880.     }
  2881. ;
  2882.  
  2883. /*
  2884.  *  openable: container
  2885.  *
  2886.  *  A container that can be opened and closed.  The isopenable
  2887.  *  property is set to true.  The default ldesc displays
  2888.  *  the contents of the container if the container is open, otherwise
  2889.  *  a message saying that the object is closed.
  2890.  */
  2891. class openable: container
  2892.     contentsReachable = { return( self.isopen ); }
  2893.     contentsVisible = { return( self.isopen ); }
  2894.     isopenable = true
  2895.     ldesc =
  2896.     {
  2897.         caps(); self.thedesc;
  2898.         if ( self.isopen )
  2899.     {
  2900.         " is open. ";
  2901.         pass ldesc;
  2902.     }
  2903.         else
  2904.     {
  2905.         " is closed. ";
  2906.  
  2907.         /* if it's transparent, list its contents anyway */
  2908.         if (isclass(self, transparentItem)) pass ldesc;
  2909.     }
  2910.     }
  2911.     isopen = true
  2912.     verDoOpen( actor ) =
  2913.     {
  2914.         if ( self.isopen )
  2915.     {
  2916.         caps(); self.thedesc; " is already open! ";
  2917.     }
  2918.     }
  2919.     doOpen( actor ) =
  2920.     {
  2921.         if (itemcnt( self.contents ))
  2922.     {
  2923.         "Opening "; self.thedesc; " reveals "; listcont( self ); ". ";
  2924.     }
  2925.     else "Opened. ";
  2926.     self.isopen := true;
  2927.     }
  2928.     verDoClose( actor ) =
  2929.     {
  2930.         if ( not self.isopen )
  2931.     {
  2932.         caps(); self.thedesc; " is already closed! ";
  2933.     }
  2934.     }
  2935.     doClose( actor ) =
  2936.     {
  2937.         "Closed. ";
  2938.     self.isopen := nil;
  2939.     }
  2940.     verIoPutIn( actor ) =
  2941.     {
  2942.         if ( not self.isopen )
  2943.     {
  2944.         caps(); self.thedesc; " is closed. ";
  2945.     }
  2946.     }
  2947.     verDoLookin( actor ) =
  2948.     {
  2949.         /* we can look in it if either it's open or it's transparent */
  2950.         if (not self.isopen and not isclass(self, transparentItem))
  2951.            "It's closed. ";
  2952.     }
  2953. ;
  2954.  
  2955. /*
  2956.  *  qcontainer: container
  2957.  *
  2958.  *  A "quiet" container:  its contents are not listed when it shows
  2959.  *  up in a room description or inventory list.  The isqcontainer
  2960.  *  property is set to true.
  2961.  */
  2962. class qcontainer: container
  2963.     isqcontainer = true
  2964. ;
  2965.  
  2966. /*
  2967.  *  lockable: openable
  2968.  *
  2969.  *  A container that can be locked and unlocked.  The islocked
  2970.  *  property specifies whether the object can be opened or not.  The
  2971.  *  object can be locked and unlocked without the need for any other
  2972.  *  object; if you want a key to be involved, use a keyedLockable.
  2973.  */
  2974. class lockable: openable
  2975.     verDoOpen( actor ) =
  2976.     {
  2977.         if ( self.islocked )
  2978.         {
  2979.             "It's locked. ";
  2980.         }
  2981.         else pass verDoOpen;
  2982.     }
  2983.     verDoLock( actor ) =
  2984.     {
  2985.         if ( self.islocked )
  2986.         {
  2987.             "It's already locked! ";
  2988.         }
  2989.     }
  2990.     doLock( actor ) =
  2991.     {
  2992.         if ( self.isopen )
  2993.         {
  2994.             "%You%'ll have to close "; self.thedesc; " first. ";
  2995.         }
  2996.         else
  2997.         {
  2998.             "Locked. ";
  2999.             self.islocked := true;
  3000.         }
  3001.     }
  3002.     verDoUnlock( actor ) =
  3003.     {
  3004.         if ( not self.islocked ) "It's not locked! ";
  3005.     }
  3006.     doUnlock( actor ) =
  3007.     {
  3008.         "Unlocked. ";
  3009.         self.islocked := nil;
  3010.     }
  3011.     verDoLockWith( actor, io ) =
  3012.     {
  3013.         if ( self.islocked ) "It's already locked. ";
  3014.     }
  3015.     verDoUnlockWith( actor, io ) =
  3016.     {
  3017.         if ( not self.islocked ) "It's not locked! ";
  3018.     }
  3019. ;
  3020.  
  3021. /*
  3022.  *  keyedLockable: lockable
  3023.  *
  3024.  *  This subclass of lockable allows you to create an object
  3025.  *  that can only be locked and unlocked with a corresponding key.
  3026.  *  Set the property mykey to the keyItem object that can
  3027.  *  lock and unlock the object.
  3028.  */
  3029. class keyedLockable: lockable
  3030.     mykey = nil     // set 'mykey' to the key which locks/unlocks me
  3031.     doLock( actor ) =
  3032.     {
  3033.         askio( withPrep );
  3034.     }
  3035.     doUnlock( actor ) =
  3036.     {
  3037.         askio( withPrep );
  3038.     }
  3039.     doLockWith( actor, io ) =
  3040.     {
  3041.         if ( self.isopen )
  3042.         {
  3043.             "%You% can't lock << self.thedesc >> when it's open. ";
  3044.         }
  3045.         else if ( io = self.mykey )
  3046.         {
  3047.             "Locked. ";
  3048.             self.islocked := true;
  3049.         }
  3050.         else "It doesn't fit the lock. ";
  3051.     }
  3052.     doUnlockWith( actor, io ) =
  3053.     {
  3054.         if ( io = self.mykey )
  3055.         {
  3056.             "Unlocked. ";
  3057.             self.islocked := nil;
  3058.         }
  3059.         else "It doesn't fit the lock. ";
  3060.     }
  3061. ;
  3062.  
  3063. /*
  3064.  *  keyItem: item
  3065.  *
  3066.  *  This is an object that can be used as a key for a keyedLockable
  3067.  *  or lockableDoorway object.  It otherwise behaves as an ordinary item.
  3068.  */
  3069. class keyItem: item
  3070.     verIoUnlockWith( actor ) = {}
  3071.     ioUnlockWith( actor, dobj ) =
  3072.     {
  3073.         dobj.doUnlockWith( actor, self );
  3074.     }
  3075.     verIoLockWith( actor ) = {}
  3076.     ioLockWith( actor, dobj ) =
  3077.     {
  3078.         dobj.doLockWith( actor, self );
  3079.     }
  3080. ;
  3081.  
  3082. /*
  3083.  *  seethruItem: item
  3084.  *
  3085.  *  This is an object that the player can look through, such as a window.
  3086.  *  The thrudesc method displays a message for when the player looks
  3087.  *  through the object (with a command such as "look through window").
  3088.  *  Note this is not the same as a transparentItem, whose contents
  3089.  *  are visible from outside the object.
  3090.  */
  3091. class seethruItem: item
  3092.     verDoLookthru(actor) = {}
  3093.     doLookthru(actor) = { self.thrudesc; }
  3094. ;
  3095.  
  3096.  
  3097. /*
  3098.  *  transparentItem: item
  3099.  *
  3100.  *  An object whose contents are visible, even when the object is
  3101.  *  closed.  Whether the contents are reachable is decided in the
  3102.  *  normal fashion.  This class is useful for items such as glass
  3103.  *  bottles, whose contents can be seen when the bottle is closed
  3104.  *  but cannot be reached.
  3105.  */
  3106. class transparentItem: item
  3107.     contentsVisible = { return( true ); }
  3108.     ldesc =
  3109.     {
  3110.         if (self.contentsVisible and itemcnt(self.contents) <> 0)
  3111.         {
  3112.             "In "; self.thedesc; " %you% see%s% "; listcont(self); ". ";
  3113.         }
  3114.         else
  3115.         {
  3116.             "There's nothing in "; self.thedesc; ". ";
  3117.         }
  3118.     }
  3119.     verGrab( obj ) =
  3120.     {
  3121.         if ( self.isopenable and not self.isopen )
  3122.             "%You% will have to open << self.thedesc >> first. ";
  3123.     }
  3124.     doOpen( actor ) =
  3125.     {
  3126.         self.isopen := true;
  3127.         "Opened. ";
  3128.     }
  3129.     verDoLookin(actor) = {}
  3130.     doLookin(actor) = { self.ldesc; }
  3131. ;
  3132.  
  3133. /*
  3134.  *  basicNumObj: object
  3135.  *
  3136.  *  This object provides a default implementation for numObj.
  3137.  *  To use this default unchanged in your game, include in your
  3138.  *  game this line:  "numObj: basicNumObj".
  3139.  */
  3140. class basicNumObj: object   // when a number is used in a player command,
  3141.     value = 0               //  this is set to its value
  3142.     sdesc = "<<value>>"
  3143.     adesc = "a number"
  3144.     thedesc = "the number <<value>>"
  3145.     verDoTypeOn( actor, io ) = {}
  3146.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  3147.     verIoTurnTo( actor ) = {}
  3148.     ioTurnTo( actor, dobj ) = { dobj.doTurnTo( actor, self ); }
  3149. ;
  3150.  
  3151. /*
  3152.  *  basicStrObj: object
  3153.  *
  3154.  *  This object provides a default implementation for strObj.
  3155.  *  To use this default unchanged in your game, include in your
  3156.  *  game this line:  "strObj: basicStrObj".
  3157.  */
  3158. class basicStrObj: object   // when a string is used in a player command,
  3159.     value = ''              //  this is set to its value
  3160.     sdesc = "\"<<value>>\""
  3161.     adesc = "\"<<value>>\""
  3162.     thedesc = "\"<<value>>\""
  3163.     verDoTypeOn( actor, io ) = {}
  3164.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  3165.     doSynonym('TypeOn') = 'EnterOn' 'EnterIn' 'EnterWith'
  3166.     verDoSave( actor ) = {}
  3167.     saveGame(actor) =
  3168.     {
  3169.         if (save( self.value ))
  3170.     {
  3171.             "Save failed. ";
  3172.         return nil;
  3173.     }
  3174.         else
  3175.     {
  3176.             "Saved. ";
  3177.         return true;
  3178.     }
  3179.     }
  3180.     doSave( actor ) =
  3181.     {
  3182.     self.saveGame(actor);
  3183.     abort;
  3184.     }
  3185.     verDoRestore( actor ) = {}
  3186.     restoreGame(actor) =
  3187.     {
  3188.         if (restore( self.value ))
  3189.     {
  3190.             "Restore failed. ";
  3191.         return nil;
  3192.     }
  3193.         else
  3194.     {
  3195.             "Restored.\b";
  3196.         scoreStatus( global.score, global.turnsofar );
  3197.         Me.location.lookAround(true);
  3198.         return true;
  3199.     }
  3200.     }
  3201.     doRestore( actor ) =
  3202.     {
  3203.     self.restoreGame(actor);
  3204.         abort;
  3205.     }
  3206.     verDoScript( actor ) = {}
  3207.     startScripting(actor) =
  3208.     {
  3209.         logging( self.value );
  3210.         "Writing script file. ";
  3211.     }
  3212.     doScript( actor ) =
  3213.     {
  3214.     self.startScripting(actor);
  3215.         abort;
  3216.     }
  3217.     verDoSay( actor ) = {}
  3218.     doSay( actor ) =
  3219.     {
  3220.         "Okay, \""; say( self.value ); "\".";
  3221.     }
  3222. ;
  3223.  
  3224. /*
  3225.  *  deepverb: object
  3226.  *
  3227.  *  A "verb object" that is referenced by the parser when the player
  3228.  *  uses an associated vocabulary word.  A deepverb contains both
  3229.  *  the vocabulary of the verb and a description of available syntax.
  3230.  *  The verb property lists the verb vocabulary words;
  3231.  *  one word (such as 'take') or a pair (such as 'pick up')
  3232.  *  can be used.  In the latter case, the second word must be a
  3233.  *  preposition, and may move to the end of the sentence in a player's
  3234.  *  command, as in "pick it up."  The action(actor)
  3235.  *  method specifies what happens when the verb is used without any
  3236.  *  objects; its absence specifies that the verb cannot be used without
  3237.  *  an object.  The doAction specifies the root of the message
  3238.  *  names (in single quotes) sent to the direct object when the verb
  3239.  *  is used with a direct object; its absence means that a single object
  3240.  *  is not allowed.  Likewise, the ioAction(preposition)
  3241.  *  specifies the root of the message name sent to the direct and
  3242.  *  indirect objects when the verb is used with both a direct and
  3243.  *  indirect object; its absence means that this syntax is illegal.
  3244.  *  Several ioAction properties may be present:  one for each
  3245.  *  preposition that can be used with an indirect object with the verb.
  3246.  *  
  3247.  *  The validDo(actor, object, seqno) method returns true
  3248.  *  if the indicated object is valid as a direct object for this actor.
  3249.  *  The validIo(actor, object, seqno) method does likewise
  3250.  *  for indirect objects.  The seqno parameter is a "sequence
  3251.  *  number," starting with 1 for the first object tried for a given
  3252.  *  verb, 2 for the second, and so forth; this parameter is normally
  3253.  *  ignored, but can be used for some special purposes.  For example,
  3254.  *  askVerb does not distinguish between objects matching vocabulary
  3255.  *  words, and therefore accepts only the first from a set of ambiguous
  3256.  *  objects.  These methods do not normally need to be changed; by
  3257.  *  default, they return true if the object is accessible to the
  3258.  *  actor.
  3259.  *  
  3260.  *  The doDefault(actor, prep, indirectObject) and
  3261.  *  ioDefault(actor, prep) methods return a list of the
  3262.  *  default direct and indirect objects, respectively.  These lists
  3263.  *  are used for determining which objects are meant by "all" and which
  3264.  *  should be used when the player command is missing an object.  These
  3265.  *  normally return a list of all objects that are applicable to the
  3266.  *  current command.
  3267.  *  
  3268.  *  The validDoList(actor, prep, indirectObject) and
  3269.  *  validIoList(actor, prep, directObject) methods return
  3270.  *  a list of all of the objects for which validDo would be true.
  3271.  *  Remember to include floating objects, which are generally
  3272.  *  accessible.  Note that the objects returned by this list will
  3273.  *  still be submitted by the parser to validDo, so it's okay for
  3274.  *  this routine to return too many objects.  In fact, this
  3275.  *  routine is entirely unnecessary; if you omit it altogether, or
  3276.  *  make it return nil, the parser will simply submit every
  3277.  *  object matching the player's vocabulary words to validDo.
  3278.  *  The reason to provide this method is that it can significantly
  3279.  *  improve parsing speed when the game has lots of objects that
  3280.  *  all have the same vocabulary word, because it cuts down on the
  3281.  *  number of times that validDo has to be called (each call
  3282.  *  to validDo is fairly time-consuming).
  3283.  */
  3284. class deepverb: object                // A deep-structure verb.
  3285.     validDo( actor, obj, seqno ) =
  3286.     {
  3287.         return( obj.isReachable( actor ));
  3288.     }
  3289.     validDoList(actor, prep, iobj) =
  3290.     {
  3291.     local ret;
  3292.     local loc;
  3293.  
  3294.     loc := actor.location;
  3295.     while (loc.location) loc := loc.location;
  3296.     ret := visibleList(actor) + visibleList(loc)
  3297.            + global.floatingList;
  3298.     return(ret);
  3299.     }
  3300.     validIo( actor, obj, seqno ) =
  3301.     {
  3302.         return( obj.isReachable( actor ));
  3303.     }
  3304.     validIoList(actor, prep, dobj) = (self.validDoList(actor, prep, dobj))
  3305.     doDefault( actor, prep, io ) =
  3306.     {
  3307.         return( actor.contents + actor.location.contents );
  3308.     }
  3309.     ioDefault( actor, prep ) =
  3310.     {
  3311.         return( actor.contents + actor.location.contents );
  3312.     }
  3313. ;
  3314.  
  3315. /*
  3316.    Dark verb - a verb that can be used in the dark.  Travel verbs
  3317.    are all dark verbs, as are system verbs (quit, save, etc.).
  3318.    In addition, certain special verbs are usable in the dark:  for
  3319.    example, you can drop objects you are carrying, and you can turn
  3320.    on light sources you are carrying. 
  3321. */
  3322.  
  3323. class darkVerb: deepverb
  3324.    isDarkVerb = true
  3325. ;
  3326.  
  3327. /*
  3328.  *   Various verbs.
  3329.  */
  3330. inspectVerb: deepverb
  3331.     verb = 'inspect' 'examine' 'look at' 'l at' 'x'
  3332.     sdesc = "inspect"
  3333.     doAction = 'Inspect'
  3334.     validDo( actor, obj, seqno ) =
  3335.     {
  3336.         return( obj.isVisible( actor ));
  3337.     }
  3338. ;
  3339. askVerb: deepverb
  3340.     verb = 'ask'
  3341.     sdesc = "ask"
  3342.     prepDefault = aboutPrep
  3343.     ioAction( aboutPrep ) = 'AskAbout'
  3344.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3345.     validIoList(actor, prep, dobj) = (nil)
  3346. ;
  3347. tellVerb: deepverb
  3348.     verb = 'tell'
  3349.     sdesc = "tell"
  3350.     prepDefault = aboutPrep
  3351.     ioAction( aboutPrep ) = 'TellAbout'
  3352.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3353.     validIoList(actor, prep, dobj) = (nil)
  3354.     ioDefault( actor, prep ) =
  3355.     {
  3356.         if (prep = aboutPrep)
  3357.         return([]);
  3358.     else
  3359.         return(actor.contents + actor.location.contents);
  3360.     }
  3361. ;
  3362. followVerb: deepverb
  3363.     sdesc = "follow"
  3364.     verb = 'follow'
  3365.     doAction = 'Follow'
  3366. ;
  3367. digVerb: deepverb
  3368.     verb = 'dig' 'dig in'
  3369.     sdesc = "dig in"
  3370.     prepDefault = withPrep
  3371.     ioAction( withPrep ) = 'DigWith'
  3372. ;
  3373. jumpVerb: deepverb
  3374.     verb = 'jump' 'jump over' 'jump off'
  3375.     sdesc = "jump"
  3376.     doAction = 'Jump'
  3377.     action(actor) = { "Wheeee!"; }
  3378. ;
  3379. pushVerb: deepverb
  3380.     verb = 'push' 'press'
  3381.     sdesc = "push"
  3382.     doAction = 'Push'
  3383. ;
  3384. attachVerb: deepverb
  3385.     verb = 'attach' 'connect'
  3386.     sdesc = "attach"
  3387.     prepDefault = toPrep
  3388.     ioAction( toPrep ) = 'AttachTo'
  3389. ;
  3390. wearVerb: deepverb
  3391.     verb = 'wear' 'put on'
  3392.     sdesc = "wear"
  3393.     doAction = 'Wear'
  3394. ;
  3395. dropVerb: deepverb, darkVerb
  3396.     verb = 'drop' 'put down'
  3397.     sdesc = "drop"
  3398.     ioAction( onPrep ) = 'PutOn'
  3399.     doAction = 'Drop'
  3400.     doDefault( actor, prep, io ) =
  3401.     {
  3402.         return( actor.contents );
  3403.     }
  3404. ;
  3405. removeVerb: deepverb
  3406.     verb = 'take off'
  3407.     sdesc = "take off"
  3408.     doAction = 'Unwear'
  3409.     ioAction( fromPrep ) = 'RemoveFrom'
  3410. ;
  3411. openVerb: deepverb
  3412.     verb = 'open'
  3413.     sdesc = "open"
  3414.     doAction = 'Open'
  3415. ;
  3416. closeVerb: deepverb
  3417.     verb = 'close'
  3418.     sdesc = "close"
  3419.     doAction = 'Close'
  3420. ;
  3421. putVerb: deepverb
  3422.     verb = 'put' 'place'
  3423.     sdesc = "put"
  3424.     prepDefault = inPrep
  3425.     ioAction( inPrep ) = 'PutIn'
  3426.     ioAction( onPrep ) = 'PutOn'
  3427.     doDefault( actor, prep, io ) =
  3428.     {
  3429.         return( takeVerb.doDefault( actor, prep, io ) + actor.contents );
  3430.     }
  3431. ;
  3432. takeVerb: deepverb                   // This object defines how to take things
  3433.     verb = 'take' 'pick up' 'get' 'remove'
  3434.     sdesc = "take"
  3435.     ioAction( offPrep ) = 'TakeOff'
  3436.     ioAction( outPrep ) = 'TakeOut'
  3437.     ioAction( fromPrep ) = 'TakeOut'
  3438.     ioAction( inPrep ) = 'TakeOut'
  3439.     ioAction( onPrep ) = 'TakeOff'
  3440.     doAction = 'Take'
  3441.     doDefault( actor, prep, io ) =
  3442.     {
  3443.         local ret, rem, cur, rem2, cur2, tot, i, tot2, j;
  3444.     
  3445.     ret := [];
  3446.         
  3447.     /*
  3448.      *   For "take all out/off of <iobj>", return the (non-fixed)
  3449.      *   contents of the indirect object.  Same goes for "take all in
  3450.      *   <iobj>", "take all on <iobj>", and "take all from <iobj>".
  3451.      */
  3452.     if (( prep=outPrep or prep=offPrep or prep=inPrep or prep=onPrep
  3453.      or prep=fromPrep ) and io<>nil )
  3454.     {
  3455.         rem := io.contents;
  3456.         i := 1;
  3457.         tot := length( rem );
  3458.         while ( i <= tot )
  3459.         {
  3460.             cur := rem[i];
  3461.             if (not cur.isfixed and self.validDo(actor, cur, i))
  3462.             ret += cur;
  3463.         ++i;
  3464.         }
  3465.             return( ret );
  3466.     }
  3467.  
  3468.         /*
  3469.      *   In the general case, return everything that's not fixed
  3470.      *   in the actor's location, or everything inside fixed containers
  3471.      *   that isn't itself fixed.
  3472.      */
  3473.         rem := actor.location.contents;
  3474.     tot := length( rem );
  3475.     i := 1;
  3476.         while ( i <= tot )
  3477.         {
  3478.         cur := rem[i];
  3479.             if ( cur.isfixed )
  3480.             {
  3481.                 if ((( cur.isopenable and cur.isopen ) or
  3482.                   ( not cur.isopenable )) and ( not cur.isactor ))
  3483.                 {
  3484.                     rem2 := cur.contents;
  3485.             tot2 := length( rem2 );
  3486.             j := 1;
  3487.                     while ( j <= tot2 )
  3488.                     {
  3489.                 cur2 := rem2[j];
  3490.                         if ( not cur2.isfixed and not cur2.notakeall )
  3491.             {
  3492.                 ret := ret + cur2;
  3493.             }
  3494.                         j := j + 1;
  3495.                     }
  3496.                 }
  3497.             }
  3498.             else if ( not cur.notakeall )
  3499.         {
  3500.             ret := ret + cur;
  3501.         }
  3502.  
  3503.         i := i + 1;            
  3504.         }
  3505.         return( ret );
  3506.     }
  3507. ;
  3508. plugVerb: deepverb
  3509.     verb = 'plug'
  3510.     sdesc = "plug"
  3511.     prepDefault = inPrep
  3512.     ioAction( inPrep ) = 'PlugIn'
  3513. ;
  3514. lookInVerb: deepverb
  3515.     verb = 'look in' 'look on' 'l in' 'l on'
  3516.     sdesc = "look in"
  3517.     doAction = 'Lookin'
  3518. ;
  3519. screwVerb: deepverb
  3520.     verb = 'screw'
  3521.     sdesc = "screw"
  3522.     ioAction( withPrep ) = 'ScrewWith'
  3523.     doAction = 'Screw'
  3524. ;
  3525. unscrewVerb: deepverb
  3526.     verb = 'unscrew'
  3527.     sdesc = "unscrew"
  3528.     ioAction( withPrep ) = 'UnscrewWith'
  3529.     doAction = 'Unscrew'
  3530. ;
  3531. turnVerb: deepverb
  3532.     verb = 'turn' 'rotate' 'twist'
  3533.     sdesc = "turn"
  3534.     ioAction( toPrep ) = 'TurnTo'
  3535.     ioAction( withPrep ) = 'TurnWith'
  3536.     doAction = 'Turn'
  3537. ;
  3538. switchVerb: deepverb
  3539.     verb = 'switch'
  3540.     sdesc = "switch"
  3541.     doAction = 'Switch'
  3542. ;
  3543. flipVerb: deepverb
  3544.     verb = 'flip'
  3545.     sdesc = "flip"
  3546.     doAction = 'Flip'
  3547. ;
  3548. turnOnVerb: deepverb, darkVerb
  3549.     verb = 'activate' 'turn on' 'switch on'
  3550.     sdesc = "turn on"
  3551.     doAction = 'Turnon'
  3552. ;
  3553. turnOffVerb: deepverb
  3554.     verb = 'turn off' 'deactiv' 'switch off'
  3555.     sdesc = "turn off"
  3556.     doAction = 'Turnoff'
  3557. ;
  3558. lookVerb: deepverb
  3559.     verb = 'look' 'l' 'look around' 'l around'
  3560.     sdesc = "look"
  3561.     action( actor ) =
  3562.     {
  3563.         actor.location.lookAround( true );
  3564.     }
  3565. ;
  3566. sitVerb: deepverb
  3567.     verb = 'sit on' 'sit in' 'sit' 'sit down' 'sit downin' 'sit downon'
  3568.     sdesc = "sit on"
  3569.     doAction = 'Siton'
  3570. ;
  3571. lieVerb: deepverb
  3572.     verb = 'lie' 'lie on' 'lie in' 'lie down' 'lie downon' 'lie downin'
  3573.     sdesc = "lie on"
  3574.     doAction = 'Lieon'
  3575. ;
  3576. getOutVerb: deepverb
  3577.     verb = 'get out' 'get outof' 'get off' 'get offof'
  3578.     sdesc = "get out of"
  3579.     doAction = 'Unboard'
  3580.     action(actor) = { askdo; }
  3581.     doDefault( actor, prep, io ) =
  3582.     {
  3583.         if ( actor.location and actor.location.location )
  3584.             return( [] + actor.location );
  3585.         else return( [] );
  3586.     }
  3587. ;
  3588. boardVerb: deepverb
  3589.     verb = 'get in' 'get into' 'board' 'get on'
  3590.     sdesc = "get on"
  3591.     doAction = 'Board'
  3592. ;
  3593. againVerb: darkVerb         // Required verb:  repeats last command.  No
  3594.                             // action routines are necessary; this one's
  3595.                             // handled internally by the parser.
  3596.     verb = 'again' 'g'
  3597. ;
  3598. waitVerb: darkVerb
  3599.     verb = 'wait' 'z'
  3600.     action( actor ) =
  3601.     {
  3602.         "Time passes...\n";
  3603.     }
  3604. ;
  3605. iVerb: deepverb
  3606.     verb = 'inventory' 'i'
  3607.     action( actor ) =
  3608.     {
  3609.         if (length( actor.contents ))
  3610.         {
  3611.             "%You% %have% "; listcont( actor ); ". ";
  3612.             listcontcont( actor );
  3613.         }
  3614.     else
  3615.             "%You% %are% empty-handed.\n";
  3616.     }
  3617. ;
  3618. lookThruVerb: deepverb
  3619.     verb = 'look through' 'look thru' 'l through' 'l thru'
  3620.     sdesc = "look through"
  3621.     doAction = 'Lookthru'
  3622. ;
  3623. breakVerb: deepverb
  3624.     verb = 'break' 'ruin' 'destroy'
  3625.     sdesc = "break"
  3626.     doAction = 'Break'
  3627. ;
  3628. attackVerb: deepverb
  3629.     verb = 'attack' 'kill' 'hit'
  3630.     sdesc = "attack"
  3631.     prepDefault = withPrep
  3632.     ioAction( withPrep ) = 'AttackWith'
  3633. ;
  3634. climbVerb: deepverb
  3635.     verb = 'climb'
  3636.     sdesc = "climb"
  3637.     doAction = 'Climb'
  3638. ;
  3639. eatVerb: deepverb
  3640.     verb = 'eat' 'consume'
  3641.     sdesc = "eat"
  3642.     doAction = 'Eat'
  3643. ;
  3644. drinkVerb: deepverb
  3645.     verb = 'drink'
  3646.     sdesc = "drink"
  3647.     doAction = 'Drink'
  3648. ;
  3649. giveVerb: deepverb
  3650.     verb = 'give' 'offer'
  3651.     sdesc = "give"
  3652.     prepDefault = toPrep
  3653.     ioAction( toPrep ) = 'GiveTo'
  3654.     doDefault( actor, prep, io ) =
  3655.     {
  3656.         return( actor.contents );
  3657.     }
  3658. ;
  3659. pullVerb: deepverb
  3660.     verb = 'pull'
  3661.     sdesc = "pull"
  3662.     doAction = 'Pull'
  3663. ;
  3664. readVerb: deepverb
  3665.     verb = 'read'
  3666.     sdesc = "read"
  3667.     doAction = 'Read'
  3668. ;
  3669. throwVerb: deepverb
  3670.     verb = 'throw' 'toss'
  3671.     sdesc = "throw"
  3672.     prepDefault = atPrep
  3673.     ioAction( atPrep ) = 'ThrowAt'
  3674.     ioAction( toPrep ) = 'ThrowTo'
  3675. ;
  3676. standOnVerb: deepverb
  3677.     verb = 'stand on'
  3678.     sdesc = "stand on"
  3679.     doAction = 'Standon'
  3680. ;
  3681. standVerb: deepverb
  3682.     verb = 'stand' 'stand up' 'get up'
  3683.     sdesc = "stand"
  3684.     action( actor ) =
  3685.     {
  3686.         if ( actor.location=nil or actor.location.location = nil )
  3687.             "%You're% already standing! ";
  3688.         else
  3689.         {
  3690.         actor.location.doUnboard( actor );
  3691.         }
  3692.     }
  3693. ;
  3694. helloVerb: deepverb
  3695.     verb = 'hello' 'hi' 'greetings'
  3696.     action( actor ) =
  3697.     {
  3698.         "Nice weather we've been having.\n";
  3699.     }
  3700. ;
  3701. showVerb: deepverb
  3702.     verb = 'show'
  3703.     sdesc = "show"
  3704.     prepDefault = toPrep
  3705.     ioAction( toPrep ) = 'ShowTo'
  3706.     doDefault( actor, prep, io ) =
  3707.     {
  3708.         return( actor.contents );
  3709.     }
  3710. ;
  3711. cleanVerb: deepverb
  3712.     verb = 'clean'
  3713.     sdesc = "clean"
  3714.     ioAction( withPrep ) = 'CleanWith'
  3715.     doAction = 'Clean'
  3716. ;
  3717. sayVerb: deepverb
  3718.     verb = 'say'
  3719.     sdesc = "say"
  3720.     doAction = 'Say'
  3721. ;
  3722. yellVerb: deepverb
  3723.     verb = 'yell' 'shout' 'yell at' 'shout at'
  3724.     action( actor ) =
  3725.     {
  3726.         "%Your% throat is a bit sore now. ";
  3727.     }
  3728. ;
  3729. moveVerb: deepverb
  3730.     verb = 'move'
  3731.     sdesc = "move"
  3732.     ioAction( withPrep ) = 'MoveWith'
  3733.     ioAction( toPrep ) = 'MoveTo'
  3734.     doAction = 'Move'
  3735. ;
  3736. fastenVerb: deepverb
  3737.     verb = 'fasten' 'buckle' 'buckle up'
  3738.     sdesc = "fasten"
  3739.     doAction = 'Fasten'
  3740. ;
  3741. unfastenVerb: deepverb
  3742.     verb = 'unfasten' 'unbuckle'
  3743.     sdesc = "unfasten"
  3744.     doAction = 'Unfasten'
  3745. ;
  3746. unplugVerb: deepverb
  3747.     verb = 'unplug'
  3748.     sdesc = "unplug"
  3749.     ioAction( fromPrep ) = 'UnplugFrom'
  3750.     doAction = 'Unplug'
  3751. ;
  3752. lookUnderVerb: deepverb
  3753.     verb = 'look under' 'look beneath' 'l under' 'l beneath'
  3754.     sdesc = "look under"
  3755.     doAction = 'Lookunder'
  3756. ;
  3757. lookBehindVerb: deepverb
  3758.     verb = 'look behind' 'l behind'
  3759.     sdesc = "look behind"
  3760.     doAction = 'Lookbehind'
  3761. ;
  3762. typeVerb: deepverb
  3763.     verb = 'type'
  3764.     sdesc = "type"
  3765.     prepDefault = onPrep
  3766.     ioAction( onPrep ) = 'TypeOn'
  3767. ;
  3768. lockVerb: deepverb
  3769.     verb = 'lock'
  3770.     sdesc = "lock"
  3771.     ioAction( withPrep ) = 'LockWith'
  3772.     doAction = 'Lock'
  3773.     prepDefault = withPrep
  3774. ;
  3775. unlockVerb: deepverb
  3776.     verb = 'unlock'
  3777.     sdesc = "unlock"
  3778.     ioAction( withPrep ) = 'UnlockWith'
  3779.     doAction = 'Unlock'
  3780.     prepDefault = withPrep
  3781. ;
  3782. detachVerb: deepverb
  3783.     verb = 'detach' 'disconnect'
  3784.     prepDefault = fromPrep
  3785.     ioAction( fromPrep ) = 'DetachFrom'
  3786.     doAction = 'Detach'
  3787.     sdesc = "detach"
  3788. ;
  3789. sleepVerb: darkVerb
  3790.     action( actor ) =
  3791.     {
  3792.         if ( actor.cantSleep )
  3793.             "%You% %are% much too anxious worrying about %your% continued
  3794.             survival to fall asleep now. ";
  3795.         else if ( global.awakeTime+1 < global.sleepTime )
  3796.             "%You're% not tired. ";
  3797.         else if ( not ( actor.location.isbed or actor.location.ischair ))
  3798.             "I don't know about you, but I can never sleep
  3799.             standing up. %You% should find a nice comfortable
  3800.             bed somewhere. ";
  3801.         else
  3802.         {
  3803.             "%You% quickly drift%s% off into dreamland...\b";
  3804.             goToSleep();
  3805.         }
  3806.     }
  3807.     verb = 'sleep'
  3808. ;
  3809. pokeVerb: deepverb
  3810.     verb = 'poke' 'jab'
  3811.     sdesc = "poke"
  3812.     doAction = 'Poke'
  3813. ;
  3814. touchVerb: deepverb
  3815.     verb = 'touch'
  3816.     sdesc = "touch"
  3817.     doAction = 'Touch'
  3818. ;
  3819. moveNVerb: deepverb
  3820.     verb = 'move north' 'move n' 'push north' 'push n'
  3821.     sdesc = "move north"
  3822.     doAction = 'MoveN'
  3823. ;
  3824. moveSVerb: deepverb
  3825.     verb = 'move south' 'move s' 'push south' 'push s'
  3826.     sdesc = "move south"
  3827.     doAction = 'MoveS'
  3828. ;
  3829. moveEVerb: deepverb
  3830.     verb = 'move east' 'move e' 'push east' 'push e'
  3831.     sdesc = "move east"
  3832.     doAction = 'MoveE'
  3833. ;
  3834. moveWVerb: deepverb
  3835.     verb = 'move west' 'move w' 'push west' 'push w'
  3836.     sdesc = "move west"
  3837.     doAction = 'MoveW'
  3838. ;
  3839. moveNEVerb: deepverb
  3840.     verb = 'move northeast' 'move ne' 'push northeast' 'push ne'
  3841.     sdesc = "move northeast"
  3842.     doAction = 'MoveNE'
  3843. ;
  3844. moveNWVerb: deepverb
  3845.     verb = 'move northwest' 'move nw' 'push northwest' 'push nw'
  3846.     sdesc = "move northwest"
  3847.     doAction = 'MoveNW'
  3848. ;
  3849. moveSEVerb: deepverb
  3850.     verb = 'move southeast' 'move se' 'push southeast' 'push se'
  3851.     sdesc = "move southeast"
  3852.     doAction = 'MoveSE'
  3853. ;
  3854. moveSWVerb: deepverb
  3855.     verb = 'move southwest' 'move sw' 'push southwest' 'push sw'
  3856.     sdesc = "move southwest"
  3857.     doAction = 'MoveSW'
  3858. ;
  3859. centerVerb: deepverb
  3860.     verb = 'center'
  3861.     sdesc = "center"
  3862.     doAction = 'Center'
  3863. ;
  3864. searchVerb: deepverb
  3865.     verb = 'search'
  3866.     sdesc = "search"
  3867.     doAction = 'Search'
  3868. ;
  3869.  
  3870. /*
  3871.  *   Travel verbs  - these verbs allow the player to move about.
  3872.  *   All travel verbs have the property isTravelVerb set true.
  3873.  */
  3874. class travelVerb: deepverb, darkVerb
  3875.     isTravelVerb = true
  3876. ;
  3877.  
  3878. eVerb: travelVerb
  3879.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3880.     verb = 'e' 'east' 'go east'
  3881.     travelDir( actor ) = { return( actor.location.east ); }
  3882. ;
  3883. sVerb: travelVerb
  3884.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3885.     verb = 's' 'south' 'go south'
  3886.     travelDir( actor ) = { return( actor.location.south ); }
  3887. ;
  3888. nVerb: travelVerb
  3889.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3890.     verb = 'n' 'north' 'go north'
  3891.     travelDir( actor ) = { return( actor.location.north ); }
  3892. ;
  3893. wVerb: travelVerb
  3894.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3895.     verb = 'w' 'west' 'go west'
  3896.     travelDir( actor ) = { return( actor.location.west ); }
  3897. ;
  3898. neVerb: travelVerb
  3899.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3900.     verb = 'ne' 'northeast' 'go ne' 'go northeast'
  3901.     travelDir( actor ) = { return( actor.location.ne ); }
  3902. ;
  3903. nwVerb: travelVerb
  3904.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3905.     verb = 'nw' 'northwest' 'go nw' 'go northwest'
  3906.     travelDir( actor ) = { return( actor.location.nw ); }
  3907. ;
  3908. seVerb: travelVerb
  3909.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3910.     verb = 'se' 'southeast' 'go se' 'go southeast'
  3911.     travelDir( actor ) = { return( actor.location.se ); }
  3912. ;
  3913. swVerb: travelVerb
  3914.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3915.     verb = 'sw' 'southwest' 'go sw' 'go southwest'
  3916.     travelDir( actor ) = { return( actor.location.sw ); }
  3917. ;
  3918. inVerb: travelVerb
  3919.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3920.     verb = 'in' 'go in' 'enter'
  3921.     sdesc = "enter"
  3922.     doAction = 'Enter'
  3923.     travelDir( actor ) = { return( actor.location.in ); }
  3924.     ioAction(onPrep) = 'EnterOn'
  3925.     ioAction(inPrep) = 'EnterIn'
  3926.     ioAction(withPrep) = 'EnterWith'
  3927. ;
  3928. outVerb: travelVerb
  3929.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3930.     verb = 'out' 'go out' 'exit' 'leave'
  3931.     travelDir( actor ) = { return( actor.location.out ); }
  3932. ;
  3933. dVerb: travelVerb
  3934.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3935.     verb = 'd' 'down' 'go down'
  3936.     travelDir( actor ) = { return( actor.location.down ); }
  3937. ;
  3938. uVerb: travelVerb
  3939.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3940.     verb = 'u' 'up' 'go up'
  3941.     travelDir( actor ) = { return( actor.location.up ); }
  3942. ;
  3943.  
  3944. /*
  3945.  *   sysverb:  A system verb.  Verbs of this class are special verbs that
  3946.  *   can be executed without certain normal validations.  For example,
  3947.  *   a system verb can be executed in a dark room.  System verbs are
  3948.  *   for operations such as saving, restoring, and quitting, which are
  3949.  *   not really part of the game.
  3950.  */
  3951. class sysverb: deepverb, darkVerb
  3952.     issysverb = true
  3953. ;
  3954.  
  3955. quitVerb: sysverb
  3956.     verb = 'quit'
  3957.     quitGame(actor) =
  3958.     {
  3959.         local yesno;
  3960.  
  3961.         scoreRank();
  3962.         "\bDo you really want to quit? (YES or NO) > ";
  3963.         yesno := yorn();
  3964.         "\b";
  3965.         if ( yesno = 1 )
  3966.         {
  3967.             terminate();    // allow user good-bye message
  3968.         quit();
  3969.         }
  3970.         else
  3971.         {
  3972.             "Okay. ";
  3973.         }
  3974.     }
  3975.     action( actor ) =
  3976.     {
  3977.     self.quitGame(actor);
  3978.     abort;
  3979.     }
  3980. ;
  3981. verboseVerb: sysverb
  3982.     verb = 'verbose'
  3983.     verboseMode(actor) =
  3984.     {
  3985.         "Okay, now in VERBOSE mode.\n";
  3986.         global.verbose := true;
  3987.     Me.location.lookAround( true );
  3988.     }
  3989.     action( actor ) =
  3990.     {
  3991.     self.verboseMode(actor);
  3992.     abort;
  3993.     }
  3994. ;
  3995. terseVerb: sysverb
  3996.     verb = 'brief' 'terse'
  3997.     terseMode(actor) =
  3998.     {
  3999.         "Okay, now in TERSE mode.\n";
  4000.         global.verbose := nil;
  4001.     }
  4002.     action( actor ) =
  4003.     {
  4004.     self.terseMode(actor);
  4005.     abort;
  4006.     }
  4007. ;
  4008. scoreVerb: sysverb
  4009.     verb = 'score' 'status'
  4010.     showScore(actor) =
  4011.     {
  4012.         scoreRank();
  4013.     }
  4014.     action( actor ) =
  4015.     {
  4016.     self.showScore(actor);
  4017.     abort;
  4018.     }
  4019. ;
  4020. saveVerb: sysverb
  4021.     verb = 'save'
  4022.     sdesc = "save"
  4023.     doAction = 'Save'
  4024.     saveGame(actor) =
  4025.     {
  4026.         local savefile;
  4027.     
  4028.     savefile := askfile( 'File to save game in' );
  4029.     if ( savefile = nil or savefile = '' )
  4030.         {
  4031.         "Failed. ";
  4032.             return nil;
  4033.     }
  4034.     else if (save( savefile ))
  4035.         {
  4036.         "Saved failed. ";
  4037.             return nil;
  4038.     }
  4039.     else
  4040.     {
  4041.         "Saved. ";
  4042.             return true;
  4043.     }
  4044.     }
  4045.     action( actor ) =
  4046.     {
  4047.     self.saveGame(actor);
  4048.     abort;
  4049.     }
  4050. ;
  4051. restoreVerb: sysverb
  4052.     verb = 'restore'
  4053.     sdesc = "restore"
  4054.     doAction = 'Restore'
  4055.     restoreGame(actor) =
  4056.     {
  4057.         local savefile;
  4058.     
  4059.     savefile := askfile( 'File to restore game from' );
  4060.     if ( savefile = nil or savefile = '' )
  4061.         {
  4062.         "Failed. ";
  4063.             return nil;
  4064.     }
  4065.     else if (restore( savefile ))
  4066.         {
  4067.         "Restore failed. ";
  4068.             return nil;
  4069.     }
  4070.     else
  4071.     {
  4072.         scoreStatus(global.score, global.turnsofar);
  4073.         "Restored.\b";
  4074.         Me.location.lookAround(true);
  4075.         return true;
  4076.     }
  4077.     }
  4078.     action( actor ) =
  4079.     {
  4080.     self.restoreGame(actor);
  4081.     abort;
  4082.     }
  4083. ;
  4084. scriptVerb: sysverb
  4085.     verb = 'script'
  4086.     doAction = 'Script'
  4087.     startScripting(actor) =
  4088.     {
  4089.         local scriptfile;
  4090.     
  4091.     scriptfile := askfile( 'File to write transcript to' );
  4092.     if ( scriptfile = nil or scriptfile = '' )
  4093.         "Failed. ";
  4094.     else
  4095.     {
  4096.         logging( scriptfile );
  4097.         "All text will now be saved to the script file.
  4098.             Type UNSCRIPT at any time to discontinue scripting.";
  4099.     }
  4100.     }
  4101.     action( actor ) =
  4102.     {
  4103.     self.startScripting(actor);
  4104.     abort;
  4105.     }
  4106. ;
  4107. unscriptVerb: sysverb
  4108.     verb = 'unscript'
  4109.     stopScripting(actor) =
  4110.     {
  4111.         logging( nil );
  4112.         "Script closed.\n";
  4113.     }
  4114.     action( actor ) =
  4115.     {
  4116.     self.stopScripting(actor);
  4117.         abort;
  4118.     }
  4119. ;
  4120. restartVerb: sysverb
  4121.     verb = 'restart'
  4122.     restartGame(actor) =
  4123.     {
  4124.         local yesno;
  4125.         while ( true )
  4126.         {
  4127.             "Are you sure you want to start over? (YES or NO) > ";
  4128.             yesno := yorn();
  4129.             if ( yesno = 1 )
  4130.             {
  4131.                 "\n";
  4132.         scoreStatus(0, 0);
  4133.                 restart(initRestart, global.initRestartParam);
  4134.                 break;
  4135.             }
  4136.             else if ( yesno = 0 )
  4137.             {
  4138.                 "\nOkay.\n";
  4139.         break;
  4140.             }
  4141.         }
  4142.     }
  4143.     action( actor ) =
  4144.     {
  4145.     self.restartGame(actor);
  4146.     abort;
  4147.     }
  4148. ;
  4149. versionVerb: sysverb
  4150.     verb = 'version'
  4151.     showVersion(actor) =
  4152.     {
  4153.         version.sdesc;
  4154.     }
  4155.     action( actor ) =
  4156.     {
  4157.     self.showVersion(actor);
  4158.         abort;
  4159.     }
  4160. ;
  4161. debugVerb: sysverb
  4162.     verb = 'debug'
  4163.     enterDebugger(actor) =
  4164.     {
  4165.     if (debugTrace())
  4166.         "You can't think this game has any bugs left in it... ";
  4167.     }
  4168.     action( actor ) =
  4169.     {
  4170.     self.enterDebugger(actor);
  4171.     abort;
  4172.     }
  4173. ;
  4174.  
  4175. undoVerb: sysverb
  4176.     verb = 'undo'
  4177.     undoMove(actor) =
  4178.     {
  4179.     /* do TWO undo's - one for this 'undo', one for previous command */
  4180.     if (undo() and undo())
  4181.     {
  4182.         "(Undoing one command)\b";
  4183.         Me.location.lookAround(true);
  4184.         scoreStatus(global.score, global.turnsofar);
  4185.     }
  4186.     else
  4187.         "No more undo information is available. ";
  4188.     }
  4189.     action(actor) =
  4190.     {
  4191.     self.undoMove(actor);
  4192.     abort;
  4193.     }
  4194. ;
  4195.  
  4196. /*
  4197.  *  Prep: object
  4198.  *
  4199.  *  A preposition.  The preposition property specifies the
  4200.  *  vocabulary word.
  4201.  */
  4202. class Prep: object
  4203. ;
  4204.  
  4205. /*
  4206.  *   Various prepositions
  4207.  */
  4208. ofPrep: Prep
  4209.     preposition = 'of'
  4210.     sdesc = "of"
  4211. ;
  4212. aboutPrep: Prep
  4213.     preposition = 'about'
  4214.     sdesc = "about"
  4215. ;
  4216. withPrep: Prep
  4217.     preposition = 'with'
  4218.     sdesc = "with"
  4219. ;
  4220. toPrep: Prep
  4221.     preposition = 'to'
  4222.     sdesc = "to"
  4223. ;
  4224. onPrep: Prep
  4225.     preposition = 'on' 'onto' 'downon' 'upon'
  4226.     sdesc = "on"
  4227. ;
  4228. inPrep: Prep
  4229.     preposition = 'in' 'into' 'downin'
  4230.     sdesc = "in"
  4231. ;
  4232. offPrep: Prep
  4233.     preposition = 'off' 'offof'
  4234.     sdesc = "off"
  4235. ;
  4236. outPrep: Prep
  4237.     preposition = 'out' 'outof'
  4238.     sdesc = "out"
  4239. ;
  4240. fromPrep: Prep
  4241.     preposition = 'from'
  4242.     sdesc = "from"
  4243. ;
  4244. betweenPrep: Prep
  4245.     preposition = 'between' 'inbetween'
  4246.     sdesc = "between"
  4247. ;
  4248. overPrep: Prep
  4249.     preposition = 'over'
  4250.     sdesc = "over"
  4251. ;
  4252. atPrep: Prep
  4253.     preposition = 'at'
  4254.     sdesc = "at"
  4255. ;
  4256. aroundPrep: Prep
  4257.     preposition = 'around'
  4258.     sdesc = "around"
  4259. ;
  4260. thruPrep: Prep
  4261.     preposition = 'through' 'thru'
  4262.     sdesc = "through"
  4263. ;
  4264. dirPrep: Prep
  4265.     preposition = 'north' 'south' 'east' 'west' 'up' 'down' 'northeast' 'ne'
  4266.                   'northwest' 'nw' 'southeast' 'se' 'southwest' 'sw'
  4267.     sdesc = "north"         // Shouldn't ever need this, but just in case
  4268. ;
  4269. underPrep: Prep
  4270.     preposition = 'under' 'beneath'
  4271.     sdesc = "under"
  4272. ;
  4273. behindPrep: Prep
  4274.     preposition = 'behind'
  4275.     sdesc = "behind"
  4276. ;
  4277.  
  4278. /*
  4279.  *   articles:  the "built-in" articles.  "The," "a," and "an" are
  4280.  *   defined.
  4281.  */
  4282. articles: object
  4283.     article = 'the' 'a' 'an'
  4284. ;
  4285.  
  4286.